Skip to content

Commit f5a2780

Browse files
committedJun 11, 2022
[DoctrineBridge] Add NAME const for UID types
This allows to refer to the constant instead of an "arbitrary" string. For example: #[ORM\Column(type: UuidType::NAME)] private $foo; Doctrine already does it this way 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`).
1 parent 8f0543d commit f5a2780

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed
 

‎CHANGELOG.md

+5
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

+3-1
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

+3-1
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)
Please sign in to comment.