diff --git a/composer.json b/composer.json index 9df8748e..a36ebf36 100644 --- a/composer.json +++ b/composer.json @@ -100,6 +100,7 @@ "require-dev": { "php-coveralls/php-coveralls": "^2.4", "phpstan/phpstan": "^1.5.3", + "phpstan/phpdoc-parser": "<2", "phpstan/phpstan-doctrine": "^1.3", "phpunit/phpunit": "^9.5", "symfony/browser-kit": "6.4.*", diff --git a/migrations/Version20241218095458.php b/migrations/Version20241218095458.php new file mode 100644 index 00000000..df19d4f8 --- /dev/null +++ b/migrations/Version20241218095458.php @@ -0,0 +1,29 @@ +addSql('ALTER TABLE node_type_fields ADD normalization_context JSON DEFAULT NULL'); + } + + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE node_type_fields DROP normalization_context'); + } +} diff --git a/src/Entity/NodeTypeField.php b/src/Entity/NodeTypeField.php index ec3b331f..397e9bbb 100644 --- a/src/Entity/NodeTypeField.php +++ b/src/Entity/NodeTypeField.php @@ -98,6 +98,14 @@ class NodeTypeField extends AbstractField implements NodeTypeFieldInterface, Ser ] private ?array $serializationGroups = null; + #[ + Serializer\Groups(['node_type']), + SymfonySerializer\Groups(['node_type']), + Serializer\Type('array'), + ORM\Column(name: 'normalization_context', type: 'json', nullable: true) + ] + private ?array $normalizationContext = null; + #[ Serializer\Groups(['node_type']), SymfonySerializer\Groups(['node_type']), @@ -330,4 +338,33 @@ public function setExcludedFromSerialization(bool $excludedFromSerialization): N return $this; } + + public function getNormalizationContext(): ?array + { + return $this->normalizationContext; + } + + public function setNormalizationContext(?array $normalizationContext): NodeTypeField + { + $this->normalizationContext = $normalizationContext; + + return $this; + } + + #[SymfonySerializer\Ignore] + public function getNormalizationContextGroups(): ?array + { + return $this->normalizationContext['groups'] ?? []; + } + + #[SymfonySerializer\Ignore] + public function setNormalizationContextGroups(?array $normalizationContextGroups): NodeTypeField + { + if (null === $normalizationContextGroups) { + $this->normalizationContext = null; + } + $this->normalizationContext['groups'] = $normalizationContextGroups; + + return $this; + } }