diff --git a/PropertyDescriber/UuidPropertyDescriber.php b/PropertyDescriber/UuidPropertyDescriber.php new file mode 100644 index 000000000..3b11dc216 --- /dev/null +++ b/PropertyDescriber/UuidPropertyDescriber.php @@ -0,0 +1,38 @@ +type = 'string'; + $property->format = 'uuid'; + $property->pattern = '^[0-9a-f]{8}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{12}$'; + $this->setNullableProperty($types[0], $property); + } + + public function supports(array $types): bool + { + return 1 === count($types) + && Type::BUILTIN_TYPE_OBJECT === $types[0]->getBuiltinType() + && (is_a($types[0]->getClassName(), Uuid::class, true) + || is_a($types[0]->getClassName(), UuidInterface::class, true)); + } +} diff --git a/Resources/config/services.xml b/Resources/config/services.xml index eb1e05cf4..2a5f19a7a 100644 --- a/Resources/config/services.xml +++ b/Resources/config/services.xml @@ -130,6 +130,10 @@ + + + +