Skip to content

Commit 49c311b

Browse files
committed
feature #46642 [DoctrineBridge] Add NAME const for UID types (marcelsiegert)
This PR was merged into the 6.2 branch. Discussion ---------- [DoctrineBridge] Add `NAME` const for UID types | Q | A | ------------- | --- | Branch? | 6.2 | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | | License | MIT | Doc PR | symfony/symfony-docs#16866 This allows to refer to the constant instead of an "arbitrary" string. For example: ```php #[ORM\Column(type: UuidType::NAME)] private $foo; ``` Doctrine [already does it this way][1] in its documentation. The name of the constant is taken from the already existing `Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineFooType` class, where a constant with a similar purpose already exists (albeit this one is `private`). Another possibility would be `UlidType::ULID` and `UuidType::UUID` as shown in Doctrine's [Custom Mapping Types][2] documentation. [1]: https://www.doctrine-project.org/projects/doctrine-orm/en/2.11/reference/basic-mapping.html [2]: https://www.doctrine-project.org/projects/doctrine-orm/en/2.11/cookbook/custom-mapping-types.html Commits ------- 0273fde6a5 [DoctrineBridge] Add `NAME` const for UID types
2 parents 1a3b643 + f5a2780 commit 49c311b

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
6.2
5+
---
6+
7+
* Add `NAME` constant to `UlidType` and `UuidType`
8+
49
6.0
510
---
611

Types/UlidType.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@
1515

1616
final class UlidType extends AbstractUidType
1717
{
18+
public const NAME = 'ulid';
19+
1820
public function getName(): string
1921
{
20-
return 'ulid';
22+
return self::NAME;
2123
}
2224

2325
protected function getUidClass(): string

Types/UuidType.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@
1515

1616
final class UuidType extends AbstractUidType
1717
{
18+
public const NAME = 'uuid';
19+
1820
public function getName(): string
1921
{
20-
return 'uuid';
22+
return self::NAME;
2123
}
2224

2325
protected function getUidClass(): string

0 commit comments

Comments
 (0)