diff --git a/composer.json b/composer.json index 858adf87..425422c1 100644 --- a/composer.json +++ b/composer.json @@ -61,6 +61,7 @@ "lexik/jwt-authentication-bundle": "^2.19", "monolog/monolog": "^1.24.0 || ^2.1.1", "nelmio/cors-bundle": "^2.2", + "nette/php-generator": "^4.1", "phpdocumentor/reflection-docblock": "^5.2", "phpoffice/phpspreadsheet": "^1.15", "psr/cache": ">=1.0.1", diff --git a/lib/EntityGenerator/composer.json b/lib/EntityGenerator/composer.json index c955cf67..bf55423f 100644 --- a/lib/EntityGenerator/composer.json +++ b/lib/EntityGenerator/composer.json @@ -14,6 +14,7 @@ "require": { "php": ">=8.2", "ext-json": "*", + "nette/php-generator": "^4.1", "roadiz/nodetype-contracts": "~1.1.2", "symfony/string": "6.4.*", "symfony/yaml": "6.4.*", diff --git a/lib/EntityGenerator/src/Attribute/AttributeGenerator.php b/lib/EntityGenerator/src/Attribute/AttributeGenerator.php deleted file mode 100644 index 2b6c07df..00000000 --- a/lib/EntityGenerator/src/Attribute/AttributeGenerator.php +++ /dev/null @@ -1,117 +0,0 @@ - - */ - protected array $parameters; - - /** - * @param string $className - * @param array $parameters - */ - public function __construct(string $className, array $parameters = []) - { - $this->className = $className; - $this->parameters = $parameters; - } - - public static function wrapString(string $string): string - { - return sprintf('"%s"', str_replace('"', '\\"', $string)); - } - - public function generate(int $currentIndentation = 0): string - { - $formattedParams = []; - if (count($this->parameters) > 3) { - foreach ($this->parameters as $name => $parameter) { - if (empty($parameter)) { - continue; - } - $formattedParams[] = $this->formatProperties($name, $parameter, $currentIndentation); - } - return - str_repeat(' ', $currentIndentation) . - $this->className . - sprintf( - '(%s%s%s)', - PHP_EOL, - implode(',' . PHP_EOL, array_filter($formattedParams)), - PHP_EOL . str_repeat(' ', $currentIndentation), - ); - } elseif (count($this->parameters) > 0) { - foreach ($this->parameters as $name => $parameter) { - if (empty($parameter)) { - continue; - } - $formattedParams[] = $this->formatProperties($name, $parameter, -4); - } - return - str_repeat(' ', $currentIndentation) . - $this->className . - sprintf( - '(%s)', - implode(', ', array_filter($formattedParams)) - ); - } else { - return str_repeat(' ', $currentIndentation) . $this->className; - } - } - - /** - * @param string $name - * @param array $parameter - * @param int $currentIndentation - * @return string - * @throws \JsonException - */ - protected function formatArrayObject(string $name, array $parameter, int $currentIndentation = 0): string - { - $encodedParameterContent = []; - foreach ($parameter as $key => $value) { - if (is_string($key)) { - $encodedParameterContent[] = sprintf( - '%s => %s', - self::wrapString($key), - \json_encode($value, \JSON_THROW_ON_ERROR) - ); - } - } - return sprintf( - '%s%s: %s', - str_repeat(' ', $currentIndentation + 4), - $name, - '[' . implode(', ', $encodedParameterContent) . ']' - ); - } - - protected function formatProperties(string|int $name, mixed $parameter, int $currentIndentation = 0): ?string - { - if (empty($parameter)) { - return null; - } - if (is_string($name) && \is_array($parameter)) { - return $this->formatArrayObject($name, $parameter, $currentIndentation); - } - if (is_string($name) && !empty($name)) { - return sprintf( - '%s%s: %s', - str_repeat(' ', $currentIndentation + 4), - $name, - $parameter - ); - } - return sprintf( - '%s%s', - str_repeat(' ', $currentIndentation + 4), - $parameter - ); - } -} diff --git a/lib/EntityGenerator/src/Attribute/AttributeListGenerator.php b/lib/EntityGenerator/src/Attribute/AttributeListGenerator.php deleted file mode 100644 index 61198a30..00000000 --- a/lib/EntityGenerator/src/Attribute/AttributeListGenerator.php +++ /dev/null @@ -1,47 +0,0 @@ - - */ - public array $attributes; - - /** - * @param AttributeGenerator[] $attributes - */ - public function __construct(array $attributes) - { - $this->attributes = $attributes; - } - - public function generate(int $currentIndentation = 0): string - { - if (count($this->attributes) === 0) { - return ''; - } - if (count($this->attributes) === 1) { - return sprintf( - '%s#[%s]', - str_repeat(' ', $currentIndentation), - reset($this->attributes)->generate() - ); - } - - return sprintf( - '%s#[%s%s%s]', - str_repeat(' ', $currentIndentation), - PHP_EOL, - implode(',' . PHP_EOL, array_map(function (AttributeGenerator $attributeGenerator) use ($currentIndentation) { - return $attributeGenerator->generate($currentIndentation + 4); - }, $this->attributes)), - PHP_EOL . str_repeat(' ', $currentIndentation), - ); - } -} diff --git a/lib/EntityGenerator/src/EntityGenerator.php b/lib/EntityGenerator/src/EntityGenerator.php index fc4a5e44..b96d8c45 100644 --- a/lib/EntityGenerator/src/EntityGenerator.php +++ b/lib/EntityGenerator/src/EntityGenerator.php @@ -4,11 +4,13 @@ namespace RZ\Roadiz\EntityGenerator; +use Nette\PhpGenerator\ClassType; +use Nette\PhpGenerator\Literal; +use Nette\PhpGenerator\PhpFile; +use Nette\PhpGenerator\PsrPrinter; use RZ\Roadiz\Contracts\NodeType\NodeTypeFieldInterface; use RZ\Roadiz\Contracts\NodeType\NodeTypeInterface; use RZ\Roadiz\Contracts\NodeType\NodeTypeResolverInterface; -use RZ\Roadiz\EntityGenerator\Attribute\AttributeGenerator; -use RZ\Roadiz\EntityGenerator\Attribute\AttributeListGenerator; use RZ\Roadiz\EntityGenerator\Field\AbstractFieldGenerator; use RZ\Roadiz\EntityGenerator\Field\CollectionFieldGenerator; use RZ\Roadiz\EntityGenerator\Field\CustomFormsFieldGenerator; @@ -24,26 +26,23 @@ use Symfony\Component\String\UnicodeString; use Symfony\Component\Yaml\Yaml; -class EntityGenerator implements EntityGeneratorInterface +final class EntityGenerator implements EntityGeneratorInterface { - protected NodeTypeInterface $nodeType; - protected NodeTypeResolverInterface $nodeTypeResolver; - protected DefaultValuesResolverInterface $defaultValuesResolver; - protected array $fieldGenerators; - protected array $options; + /** + * @var AbstractFieldGenerator[] + */ + private array $fieldGenerators; + private array $options; public function __construct( - NodeTypeInterface $nodeType, - NodeTypeResolverInterface $nodeTypeResolver, - DefaultValuesResolverInterface $defaultValuesResolver, + private readonly NodeTypeInterface $nodeType, + private readonly NodeTypeResolverInterface $nodeTypeResolver, + private readonly DefaultValuesResolverInterface $defaultValuesResolver, array $options = [] ) { $resolver = new OptionsResolver(); $this->configureOptions($resolver); - $this->nodeType = $nodeType; - $this->nodeTypeResolver = $nodeTypeResolver; - $this->defaultValuesResolver = $defaultValuesResolver; $this->fieldGenerators = []; $this->options = $resolver->resolve($options); @@ -108,7 +107,7 @@ public function configureOptions(OptionsResolver $resolver): void * @param NodeTypeFieldInterface $field * @return AbstractFieldGenerator|null */ - protected function getFieldGenerator(NodeTypeFieldInterface $field): ?AbstractFieldGenerator + private function getFieldGenerator(NodeTypeFieldInterface $field): ?AbstractFieldGenerator { if ($field->isYaml()) { return new YamlFieldGenerator($field, $this->defaultValuesResolver, $this->options); @@ -141,7 +140,7 @@ protected function getFieldGenerator(NodeTypeFieldInterface $field): ?AbstractFi return new ManyToManyFieldGenerator($field, $this->defaultValuesResolver, $this->options); } if ($field->isNodes()) { - return new NodesFieldGenerator($field, $this->nodeTypeResolver, $this->defaultValuesResolver, $this->options); + return new NodesFieldGenerator($this->nodeTypeResolver, $field, $this->defaultValuesResolver, $this->options); } if (!$field->isVirtual()) { return new NonVirtualFieldGenerator($field, $this->defaultValuesResolver, $this->options); @@ -155,129 +154,81 @@ protected function getFieldGenerator(NodeTypeFieldInterface $field): ?AbstractFi */ public function getClassContent(): string { - return $this->getClassHeader() . - $this->getClassAnnotations() . - $this->getClassAttributes() . - $this->getClassBody(); - } - - /** - * @return string - */ - protected function getClassBody(): string - { - return 'class ' . $this->nodeType->getSourceEntityClassName() . ' extends ' . $this->options['parent_class'] . ' -{' . $this->getClassProperties() . - $this->getClassConstructor() . - $this->getNodeTypeNameGetter() . - $this->getNodeTypeReachableGetter() . - $this->getNodeTypePublishableGetter() . - $this->getClassCloneMethod() . - $this->getClassMethods() . ' -}' . PHP_EOL; + $file = new PhpFile(); + $file->setStrictTypes(); + $file->addComment('THIS IS A GENERATED FILE, DO NOT EDIT IT.'); + $file->addComment('IT WILL BE RECREATED AT EACH NODE-TYPE UPDATE.'); + + $namespace = $file + ->addNamespace(trim($this->options['namespace'], '\\')) + ->addUse('Doctrine\ORM\Mapping', 'ORM') + ->addUse('JMS\Serializer\Annotation', 'JMS') + ->addUse('Symfony\Component\Serializer\Attribute', 'Serializer') + ->addUse('Gedmo\Mapping\Annotation', 'Gedmo') + ->addUse('ApiPlatform\Metadata\ApiFilter') + ->addUse('RZ\Roadiz\CoreBundle\Entity\Node') + ->addUse('RZ\Roadiz\CoreBundle\Entity\Translation') + ->addUse('ApiPlatform\Metadata\ApiProperty') + ->addUse('Doctrine\Common\Collections\Collection') + ; + + $classType = $namespace->addClass($this->nodeType->getSourceEntityClassName()) + ->setExtends($this->options['parent_class']) + ->addComment($this->nodeType->getName() . ' node-source entity.') + ->addComment($this->nodeType->getDescription() ?? ''); + + $this + ->addClassAttributes($classType) + ->addClassFields($classType) + ->addClassConstructor($classType) + ->addClassCloneMethod($classType) + ->addClassMethods($classType) + ; + return (new PsrPrinter())->printFile($file); } - /** - * @return string - */ - protected function getClassHeader(): string + private function addClassAttributes(ClassType $classType): self { - $useStatements = [ - 'use Doctrine\Common\Collections\Collection;', - 'use JMS\Serializer\Annotation as Serializer;', - 'use Symfony\Component\Serializer\Annotation as SymfonySerializer;', - 'use Gedmo\Mapping\Annotation as Gedmo;', - 'use Doctrine\ORM\Mapping as ORM;', - ]; - - if ($this->options['use_api_platform_filters'] === true) { - $useStatements[] = 'use ApiPlatform\Metadata\ApiFilter;'; - $useStatements[] = 'use ApiPlatform\Doctrine\Orm\Filter as OrmFilter;'; - $useStatements[] = 'use ApiPlatform\Serializer\Filter\PropertyFilter;'; - } - /* - * BE CAREFUL, USE statements are required for field generators which - * are using ::class syntax! - */ - return 'options['namespace'], '\\') . '; + $classType + ->addAttribute( + 'Gedmo\Mapping\Annotation\Loggable', + ['logEntryClass' => new Literal('\RZ\Roadiz\CoreBundle\Entity\UserLogEntry::class')] + ) + ->addAttribute( + 'Doctrine\ORM\Mapping\Entity', + ['repositoryClass' => new Literal($this->options['repository_class'] . '::class')] + ) + ->addAttribute( + 'Doctrine\ORM\Mapping\Table', + ['name' => $this->nodeType->getSourceEntityTableName()] + ) + ; -' . implode(PHP_EOL, $useStatements) . PHP_EOL; - } - - protected function getClassAttributes(): string - { - $attributeGenerators = [ - new AttributeGenerator('Gedmo\Loggable', [ - 'logEntryClass' => '\RZ\Roadiz\CoreBundle\Entity\UserLogEntry::class', - ]), - new AttributeGenerator('ORM\Entity', [ - 'repositoryClass' => $this->options['repository_class'] . '::class', - ]), - new AttributeGenerator('ORM\Table', [ - 'name' => AttributeGenerator::wrapString($this->nodeType->getSourceEntityTableName()) - ]) - ]; - - $indexes = []; - /** @var AbstractFieldGenerator $fieldGenerator */ foreach ($this->fieldGenerators as $fieldGenerator) { - $indexes[] = $fieldGenerator->getFieldIndex(); + $fieldGenerator->addFieldIndex($classType); } - $attributeGenerators = [...$attributeGenerators, ...array_filter($indexes)]; if ($this->options['use_api_platform_filters'] === true) { - $attributeGenerators[] = new AttributeGenerator('ApiFilter', [ - 'PropertyFilter::class' - ]); + $classType->addAttribute( + 'ApiPlatform\Metadata\ApiFilter', + [new Literal('\ApiPlatform\Serializer\Filter\PropertyFilter::class')] + ); } - return (new AttributeListGenerator($attributeGenerators))->generate() . PHP_EOL; + return $this; } - /** - * @return string - */ - protected function getClassAnnotations(): string - { - $annotations = [ - $this->nodeType->getName() . ' node-source entity.', - $this->nodeType->getDescription() - ]; - $annotations = array_filter($annotations); - - return ' -/** - * ' . implode(PHP_EOL . ' * ', $annotations) . ' - */' . PHP_EOL; - } - /** - * @return string - */ - protected function getClassProperties(): string + private function addClassFields(ClassType $classType): self { - $fieldsArray = []; - /** @var AbstractFieldGenerator $fieldGenerator */ foreach ($this->fieldGenerators as $fieldGenerator) { - $fieldsArray[] = $fieldGenerator->getField(); + $fieldGenerator->addField($classType); } - $fieldsArray = array_filter($fieldsArray); - - return implode('', $fieldsArray); + return $this; } - /** - * @return string - */ - protected function getClassCloneMethod(): string + + private function addClassCloneMethod(ClassType $classType): self { $cloneStatements = []; /** @var AbstractFieldGenerator $fieldGenerator */ @@ -287,108 +238,82 @@ protected function getClassCloneMethod(): string $cloneStatements = array_filter($cloneStatements); if (count($cloneStatements) === 0) { - return ''; + return $this; } - $statementSeparator = PHP_EOL . PHP_EOL . AbstractFieldGenerator::TAB . AbstractFieldGenerator::TAB; - $cloneStatementsString = implode($statementSeparator, $cloneStatements); + $method = $classType + ->addMethod('__clone') + ->setReturnType('void') + ; - return ' - public function __clone() - { - parent::__clone(); + $method->addBody('parent::__clone();'); + + foreach ($cloneStatements as $cloneStatement) { + $method->addBody(''); + $method->addBody($cloneStatement); + } - ' . $cloneStatementsString . ' - }' . PHP_EOL; + return $this; } - /** - * @return string - */ - protected function getClassConstructor(): string + private function addClassConstructor(ClassType $classType): self { - $constructorArray = []; - /** @var AbstractFieldGenerator $fieldGenerator */ + $constructorStatements = []; foreach ($this->fieldGenerators as $fieldGenerator) { - $constructorArray[] = $fieldGenerator->getFieldConstructorInitialization(); + $constructorStatements[] = $fieldGenerator->getFieldConstructorInitialization(); } - $constructorArray = array_filter($constructorArray); - - if (count($constructorArray) > 0) { - return ' - public function __construct(' . $this->options['node_class'] . ' $node, ' . $this->options['translation_class'] . ' $translation) - { - parent::__construct($node, $translation); - - ' . implode(PHP_EOL . AbstractFieldGenerator::TAB . AbstractFieldGenerator::TAB, $constructorArray) . ' - }' . PHP_EOL; + $constructorStatements = array_filter($constructorStatements); + + if (count($constructorStatements) > 0) { + $constructorMethod = $classType->addMethod('__construct'); + $constructorMethod->addParameter('node') + ->setType($this->options['node_class']); + $constructorMethod->addParameter('translation') + ->setType($this->options['translation_class']); + $constructorMethod->addBody('parent::__construct($node, $translation);'); + foreach ($constructorStatements as $constructorStatement) { + $constructorMethod->addBody($constructorStatement); + } } - return ''; - } - - /** - * @return string - */ - protected function getNodeTypeNameGetter(): string - { - return ' - #[ - Serializer\VirtualProperty, - Serializer\Groups(["nodes_sources", "nodes_sources_default"]), - Serializer\SerializedName("@type"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_default"]), - SymfonySerializer\SerializedName(serializedName: "@type") - ] - public function getNodeTypeName(): string - { - return \'' . $this->nodeType->getName() . '\'; - }' . PHP_EOL; + return $this; } - /** - * @return string - */ - protected function getNodeTypeReachableGetter(): string + private function addClassMethods(ClassType $classType): self { - return ' - /** - * $this->nodeType->isReachable() proxy. - * - * @return bool Does this nodeSource is reachable over network? - */ - public function isReachable(): bool - { - return ' . ($this->nodeType->isReachable() ? 'true' : 'false') . '; - }' . PHP_EOL; - } - - /** - * @return string - */ - protected function getNodeTypePublishableGetter(): string - { - return ' - /** - * $this->nodeType->isPublishable() proxy. - * - * @return bool Does this nodeSource is publishable with date and time? - */ - public function isPublishable(): bool - { - return ' . ($this->nodeType->isPublishable() ? 'true' : 'false') . '; - }' . PHP_EOL; - } - - /** - * @return string - */ - protected function getClassMethods(): string - { - return ' - public function __toString(): string - { - return \'[' . $this->nodeType->getSourceEntityClassName() . '] \' . parent::__toString(); - }'; + $classType->addMethod('getNodeTypeName') + ->setReturnType('string') + ->addAttribute('JMS\Serializer\Annotation\VirtualProperty') + ->addAttribute('JMS\Serializer\Annotation\Groups', [['nodes_sources', 'nodes_sources_default']]) + ->addAttribute('JMS\Serializer\Annotation\SerializedName', ['@type']) + ->addAttribute('Symfony\Component\Serializer\Attribute\Groups', [['nodes_sources', 'nodes_sources_default']]) + ->addAttribute('Symfony\Component\Serializer\Attribute\SerializedName', [ + 'serializedName' => '@type' + ]) + ->setBody('return \'' . $this->nodeType->getName() . '\';') + ; + + $classType->addMethod('isReachable') + ->addComment('$this->nodeType->isReachable() proxy.') + ->addComment('@return bool Does this nodeSource is reachable over network?') + ->setReturnType('bool') + ->addAttribute('JMS\Serializer\Annotation\VirtualProperty') + ->setBody('return ' . ($this->nodeType->isReachable() ? 'true' : 'false') . ';') + ; + + $classType->addMethod('isPublishable') + ->addComment('$this->nodeType->isPublishable() proxy.') + ->addComment('@return bool Does this nodeSource is publishable with date and time?') + ->setReturnType('bool') + ->addAttribute('JMS\Serializer\Annotation\VirtualProperty') + ->setBody('return ' . ($this->nodeType->isPublishable() ? 'true' : 'false') . ';') + ; + + $classType->addMethod('__toString') + ->setReturnType('string') + ->setBody('return \'[' . $this->nodeType->getSourceEntityClassName() . '] \' . parent::__toString();') + ; + + return $this; } } diff --git a/lib/EntityGenerator/src/EntityGeneratorFactory.php b/lib/EntityGenerator/src/EntityGeneratorFactory.php index 201b9064..da1facae 100644 --- a/lib/EntityGenerator/src/EntityGeneratorFactory.php +++ b/lib/EntityGenerator/src/EntityGeneratorFactory.php @@ -8,12 +8,12 @@ use RZ\Roadiz\Contracts\NodeType\NodeTypeResolverInterface; use RZ\Roadiz\EntityGenerator\Field\DefaultValuesResolverInterface; -final class EntityGeneratorFactory +final readonly class EntityGeneratorFactory { public function __construct( - private readonly NodeTypeResolverInterface $nodeTypeResolverBag, - private readonly DefaultValuesResolverInterface $defaultValuesResolver, - private readonly array $options + private NodeTypeResolverInterface $nodeTypeResolverBag, + private DefaultValuesResolverInterface $defaultValuesResolver, + private array $options ) { } diff --git a/lib/EntityGenerator/src/Field/AbstractFieldGenerator.php b/lib/EntityGenerator/src/Field/AbstractFieldGenerator.php index e0497db1..8bf539e2 100644 --- a/lib/EntityGenerator/src/Field/AbstractFieldGenerator.php +++ b/lib/EntityGenerator/src/Field/AbstractFieldGenerator.php @@ -4,112 +4,71 @@ namespace RZ\Roadiz\EntityGenerator\Field; +use Nette\PhpGenerator\ClassType; +use Nette\PhpGenerator\Literal; +use Nette\PhpGenerator\Method; +use Nette\PhpGenerator\Property; use RZ\Roadiz\Contracts\NodeType\NodeTypeFieldInterface; use RZ\Roadiz\Contracts\NodeType\SerializableInterface; -use RZ\Roadiz\EntityGenerator\Attribute\AttributeGenerator; -use RZ\Roadiz\EntityGenerator\Attribute\AttributeListGenerator; use Symfony\Component\String\UnicodeString; abstract class AbstractFieldGenerator { - public const TAB = ' '; - public const ANNOTATION_PREFIX = AbstractFieldGenerator::TAB . ' *'; - - protected NodeTypeFieldInterface $field; - protected DefaultValuesResolverInterface $defaultValuesResolver; - protected array $options; - public function __construct( - NodeTypeFieldInterface $field, - DefaultValuesResolverInterface $defaultValuesResolver, - array $options = [] + protected readonly NodeTypeFieldInterface $field, + protected readonly DefaultValuesResolverInterface $defaultValuesResolver, + protected array $options = [] ) { - $this->field = $field; - $this->defaultValuesResolver = $defaultValuesResolver; - $this->options = $options; } /** * Generate PHP code for current doctrine field. - * - * @return string */ - public function getField(): string + public function addField(ClassType $classType): void { - return $this->getFieldAnnotation() . - (new AttributeListGenerator( - $this->getFieldAttributes($this->isExcludingFieldFromJmsSerialization()) - ) - )->generate(4) . PHP_EOL . - $this->getFieldDeclaration() . - $this->getFieldGetter() . - $this->getFieldAlternativeGetter() . - $this->getFieldSetter() . PHP_EOL; + $property = $this->getFieldProperty($classType); + + $this + ->addFieldAnnotation($property) + ->addFieldAttributes($property, $this->isExcludingFieldFromJmsSerialization()) + ->addFieldGetter($classType) + ->addFieldAlternativeGetter($classType) + ->addFieldSetter($classType) + ; } - /** - * @return array - */ - protected function getFieldAutodoc(): array + protected function getFieldProperty(ClassType $classType): Property { - $docs = [ - $this->field->getLabel() . '.', - ]; + return $classType + ->addProperty($this->field->getVarName()) + ->setPrivate() + ->setType($this->getFieldTypeDeclaration()) + ->setValue($this->getFieldDefaultValueDeclaration()); + } + + protected function addFieldAutodoc(Property $property): self + { + $property->addComment($this->field->getLabel() . '.'); + if (!empty($this->field->getDescription())) { - $docs[] = $this->field->getDescription() . '.'; + $property->addComment($this->field->getDescription() . '.'); } if (!empty($this->field->getDefaultValues())) { - $docs[] = 'Default values: ' . preg_replace( - "#(?:\\r\\n|\\n)#", - PHP_EOL . " * ", - $this->field->getDefaultValues() - ); + $property->addComment('Default values:'); + $property->addComment($this->field->getDefaultValues()); } if (!empty($this->field->getGroupName())) { - $docs[] = 'Group: ' . $this->field->getGroupName() . '.'; + $property->addComment('Group: ' . $this->field->getGroupName() . '.'); } - - return array_map(function ($line) { - return (!empty(trim($line))) ? (' ' . $line) : ($line); - }, $docs); + return $this; } - /** - * @return string - */ - protected function getFieldAnnotation(): string + protected function addFieldAnnotation(Property $property): self { - $autodoc = ''; - $fieldAutoDoc = $this->getFieldAutodoc(); - if (!empty($fieldAutoDoc)) { - $autodoc = PHP_EOL . - static::ANNOTATION_PREFIX . - implode(PHP_EOL . static::ANNOTATION_PREFIX, $fieldAutoDoc); - } - return ' - /**' . $autodoc . ' - * - * (Virtual field, this var is a buffer) - */' . PHP_EOL; - } + $this->addFieldAutodoc($property); - /** - * Generate PHP property declaration block. - */ - protected function getFieldDeclaration(): string - { - $type = $this->getFieldTypeDeclaration(); - if (!empty($type)) { - $type .= ' '; - } - $defaultValue = $this->getFieldDefaultValueDeclaration(); - if (!empty($defaultValue)) { - $defaultValue = ' = ' . $defaultValue; - } - /* - * Buffer var to get referenced entities (documents, nodes, custom-forms, doctrine entities) - */ - return static::TAB . 'private ' . $type . '$' . $this->field->getVarName() . $defaultValue . ';' . PHP_EOL; + $property->addComment('(Virtual field, this var is a buffer)'); + return $this; } protected function getFieldTypeDeclaration(): string @@ -125,29 +84,24 @@ protected function toPhpDocType(string $typeHint): string $typeHint; } - protected function getFieldDefaultValueDeclaration(): string + protected function getFieldDefaultValueDeclaration(): Literal|string|null { - return ''; + return null; } - /** - * @return array - */ - protected function getFieldAttributes(bool $exclude = false): array + protected function addFieldAttributes(Property $property, bool $exclude = false): self { - $attributes = []; - if ($exclude) { - $attributes[] = new AttributeGenerator('Serializer\Exclude'); + $property->addAttribute('JMS\Serializer\Annotation\Exclude'); } /* * Symfony serializer is using getter / setter by default */ if (!$this->excludeFromSerialization()) { - $attributes[] = new AttributeGenerator('SymfonySerializer\SerializedName', [ - 'serializedName' => AttributeGenerator::wrapString($this->field->getVarName()) + $property->addAttribute('Symfony\Component\Serializer\Attribute\SerializedName', [ + 'serializedName' => $this->field->getVarName() ]); - $attributes[] = new AttributeGenerator('SymfonySerializer\Groups', [ + $property->addAttribute('Symfony\Component\Serializer\Attribute\Groups', [ $this->getSerializationGroups() ]); @@ -158,21 +112,21 @@ protected function getFieldAttributes(bool $exclude = false): array if ($this->field->isEnum() && null !== $defaultValues = $this->field->getDefaultValues()) { $enumValues = explode(',', $defaultValues); $enumValues = array_filter(array_map('trim', $enumValues)); - $openapiContext = [ + $openapiContext = array_filter([ 'type' => 'string', 'enum' => $enumValues, 'example' => $enumValues[0] ?? null, - ]; + ]); } - $attributes[] = new AttributeGenerator('\ApiPlatform\Metadata\ApiProperty', [ - 'description' => AttributeGenerator::wrapString($description), + + $property->addAttribute('ApiPlatform\Metadata\ApiProperty', array_filter([ + 'description' => $description, + 'example' => $this->field->getPlaceholder(), 'schema' => $openapiContext ?? null, - 'example' => $this->field->getPlaceholder() ? - AttributeGenerator::wrapString($this->field->getPlaceholder()) : - null, - ]); + ])); + if ($this->getSerializationMaxDepth() > 0) { - $attributes[] = new AttributeGenerator('SymfonySerializer\MaxDepth', [ + $property->addAttribute('Symfony\Component\Serializer\Attribute\MaxDepth', [ $this->getSerializationMaxDepth() ]); } @@ -184,90 +138,84 @@ protected function getFieldAttributes(bool $exclude = false): array ) { switch (true) { case $this->field->isString(): - $attributes[] = new AttributeGenerator('ApiFilter', [ - 0 => 'OrmFilter\SearchFilter::class', - 'strategy' => AttributeGenerator::wrapString('partial') + $property->addAttribute('ApiPlatform\Metadata\ApiFilter', [ + 0 => new Literal('\ApiPlatform\Doctrine\Orm\Filter\SearchFilter::class'), + 'strategy' => 'partial' ]); - $attributes[] = new AttributeGenerator('ApiFilter', [ - 0 => '\RZ\Roadiz\CoreBundle\Api\Filter\NotFilter::class' + $property->addAttribute('ApiPlatform\Metadata\ApiFilter', [ + new Literal('\RZ\Roadiz\CoreBundle\Api\Filter\NotFilter::class') ]); break; case $this->field->isMultiple(): case $this->field->isEnum(): - $attributes[] = new AttributeGenerator('ApiFilter', [ - 0 => 'OrmFilter\SearchFilter::class', - 'strategy' => AttributeGenerator::wrapString('exact') + $property->addAttribute('ApiPlatform\Metadata\ApiFilter', [ + 0 => new Literal('\ApiPlatform\Doctrine\Orm\Filter\SearchFilter::class'), + 'strategy' => 'exact' ]); - $attributes[] = new AttributeGenerator('ApiFilter', [ - 0 => '\RZ\Roadiz\CoreBundle\Api\Filter\NotFilter::class' + $property->addAttribute('ApiPlatform\Metadata\ApiFilter', [ + new Literal('\RZ\Roadiz\CoreBundle\Api\Filter\NotFilter::class') ]); break; case $this->field->isBool(): - $attributes[] = new AttributeGenerator('ApiFilter', [ - 'OrmFilter\OrderFilter::class', + $property->addAttribute('ApiPlatform\Metadata\ApiFilter', [ + new Literal('\ApiPlatform\Doctrine\Orm\Filter\OrderFilter::class'), ]); - $attributes[] = new AttributeGenerator('ApiFilter', [ - 'OrmFilter\BooleanFilter::class', + $property->addAttribute('ApiPlatform\Metadata\ApiFilter', [ + new Literal('\ApiPlatform\Doctrine\Orm\Filter\BooleanFilter::class'), ]); break; case $this->field->isManyToOne(): case $this->field->isManyToMany(): - $attributes[] = new AttributeGenerator('ApiFilter', [ - 'OrmFilter\ExistsFilter::class', + $property->addAttribute('ApiPlatform\Metadata\ApiFilter', [ + new Literal('\ApiPlatform\Doctrine\Orm\Filter\ExistsFilter::class'), ]); break; case $this->field->isInteger(): case $this->field->isDecimal(): - $attributes[] = new AttributeGenerator('ApiFilter', [ - 'OrmFilter\OrderFilter::class', + $property->addAttribute('ApiPlatform\Metadata\ApiFilter', [ + new Literal('\ApiPlatform\Doctrine\Orm\Filter\OrderFilter::class'), ]); - $attributes[] = new AttributeGenerator('ApiFilter', [ - 'OrmFilter\NumericFilter::class', + $property->addAttribute('ApiPlatform\Metadata\ApiFilter', [ + new Literal('\ApiPlatform\Doctrine\Orm\Filter\NumericFilter::class'), ]); - $attributes[] = new AttributeGenerator('ApiFilter', [ - 'OrmFilter\RangeFilter::class', + $property->addAttribute('ApiPlatform\Metadata\ApiFilter', [ + new Literal('\ApiPlatform\Doctrine\Orm\Filter\RangeFilter::class'), ]); break; case $this->field->isDate(): case $this->field->isDateTime(): - $attributes[] = new AttributeGenerator('ApiFilter', [ - 'OrmFilter\OrderFilter::class', + $property->addAttribute('ApiPlatform\Metadata\ApiFilter', [ + new Literal('\ApiPlatform\Doctrine\Orm\Filter\OrderFilter::class'), ]); - $attributes[] = new AttributeGenerator('ApiFilter', [ - 'OrmFilter\DateFilter::class', + $property->addAttribute('ApiPlatform\Metadata\ApiFilter', [ + new Literal('\ApiPlatform\Doctrine\Orm\Filter\DateFilter::class'), ]); break; } } - return $attributes; + return $this; } /** * Generate PHP alternative getter method block. - * - * @return string */ - abstract protected function getFieldGetter(): string; + abstract protected function addFieldGetter(ClassType $classType): self; /** * Generate PHP alternative getter method block. - * - * @return string */ - protected function getFieldAlternativeGetter(): string + protected function addFieldAlternativeGetter(ClassType $classType): self { - return ''; + return $this; } /** * Generate PHP setter method block. - * - * @return string */ - protected function getFieldSetter(): string + protected function addFieldSetter(ClassType $classType): self { - return ''; + return $this; } /** @@ -280,12 +228,10 @@ public function getCloneStatements(): string /** * Generate PHP annotation block for Doctrine table indexes. - * - * @return AttributeGenerator|null */ - public function getFieldIndex(): ?AttributeGenerator + public function addFieldIndex(ClassType $classType): self { - return null; + return $this; } /** @@ -340,62 +286,58 @@ protected function getDefaultSerializationGroups(): array ]; } - protected function getSerializationGroups(): string + protected function getSerializationGroups(): array { if ($this->field instanceof SerializableInterface && !empty($this->field->getSerializationGroups())) { $groups = $this->field->getSerializationGroups(); } else { $groups = $this->getDefaultSerializationGroups(); } - return '[' . implode(', ', array_map(function (string $group) { - return '"' . (new UnicodeString($group)) + return array_map(function (string $group): string { + return (new UnicodeString($group)) ->replaceMatches('/[^A-Za-z0-9]++/', '_') - ->trim('_')->toString() . '"'; - }, $groups)) . ']'; + ->trim('_')->toString(); + }, $groups); } - /** - * @return AttributeGenerator[] - */ - protected function getSerializationAttributes(): array + protected function addSerializationAttributes(Property|Method $property): self { if ($this->excludeFromSerialization()) { - return [ - new AttributeGenerator('Serializer\Exclude'), - new AttributeGenerator('SymfonySerializer\Ignore'), - ]; + $property->addAttribute('JMS\Serializer\Annotation\Exclude'); + $property->addAttribute('Symfony\Component\Serializer\Attribute\Ignore'); + return $this; } - $attributes = []; - $attributes[] = new AttributeGenerator('Serializer\Groups', [ + + $property->addAttribute('JMS\Serializer\Annotation\Groups', [ $this->getSerializationGroups() ]); if ($this->getSerializationMaxDepth() > 0) { - $attributes[] = new AttributeGenerator('Serializer\MaxDepth', [ + $property->addAttribute('JMS\Serializer\Annotation\MaxDepth', [ $this->getSerializationMaxDepth() ]); } if (null !== $this->getSerializationExclusionExpression()) { - $attributes[] = new AttributeGenerator('Serializer\Exclude', [ - 'if' => AttributeGenerator::wrapString($this->getSerializationExclusionExpression()) + $property->addAttribute('JMS\Serializer\Annotation\Exclude', [ + 'if' => $this->getSerializationExclusionExpression() ]); } switch (true) { case $this->field->isBool(): - $attributes[] = new AttributeGenerator('Serializer\Type', [ - AttributeGenerator::wrapString('bool') + $property->addAttribute('JMS\Serializer\Annotation\Type', [ + 'bool' ]); break; case $this->field->isInteger(): - $attributes[] = new AttributeGenerator('Serializer\Type', [ - AttributeGenerator::wrapString('int') + $property->addAttribute('JMS\Serializer\Annotation\Type', [ + 'int' ]); break; case $this->field->isDecimal(): - $attributes[] = new AttributeGenerator('Serializer\Type', [ - AttributeGenerator::wrapString('double') + $property->addAttribute('JMS\Serializer\Annotation\Type', [ + 'double' ]); break; case $this->field->isColor(): @@ -406,19 +348,29 @@ protected function getSerializationAttributes(): array case $this->field->isText(): case $this->field->isRichText(): case $this->field->isEnum(): - $attributes[] = new AttributeGenerator('Serializer\Type', [ - AttributeGenerator::wrapString('string') + $property->addAttribute('JMS\Serializer\Annotation\Type', [ + 'string' ]); break; case $this->field->isDateTime(): case $this->field->isDate(): - $attributes[] = new AttributeGenerator('Serializer\Type', [ - AttributeGenerator::wrapString('DateTime') + $property->addAttribute('JMS\Serializer\Annotation\Type', [ + 'DateTime' ]); break; } - return $attributes; + return $this; + } + + protected function hasFieldAlternativeGetter(): bool + { + return false; + } + + protected function hasSerializationAttributes(): bool + { + return true; } protected function isExcludingFieldFromJmsSerialization(): bool diff --git a/lib/EntityGenerator/src/Field/CollectionFieldGenerator.php b/lib/EntityGenerator/src/Field/CollectionFieldGenerator.php index ae82fe35..c075b31c 100644 --- a/lib/EntityGenerator/src/Field/CollectionFieldGenerator.php +++ b/lib/EntityGenerator/src/Field/CollectionFieldGenerator.php @@ -4,6 +4,6 @@ namespace RZ\Roadiz\EntityGenerator\Field; -class CollectionFieldGenerator extends NonVirtualFieldGenerator +final class CollectionFieldGenerator extends NonVirtualFieldGenerator { } diff --git a/lib/EntityGenerator/src/Field/CustomFormsFieldGenerator.php b/lib/EntityGenerator/src/Field/CustomFormsFieldGenerator.php index 6adc91da..2c93880a 100644 --- a/lib/EntityGenerator/src/Field/CustomFormsFieldGenerator.php +++ b/lib/EntityGenerator/src/Field/CustomFormsFieldGenerator.php @@ -4,20 +4,22 @@ namespace RZ\Roadiz\EntityGenerator\Field; -use RZ\Roadiz\EntityGenerator\Attribute\AttributeGenerator; -use RZ\Roadiz\EntityGenerator\Attribute\AttributeListGenerator; +use Nette\PhpGenerator\ClassType; +use Nette\PhpGenerator\Literal; +use Nette\PhpGenerator\Method; +use Nette\PhpGenerator\Property; -class CustomFormsFieldGenerator extends AbstractFieldGenerator +final class CustomFormsFieldGenerator extends AbstractFieldGenerator { - protected function getSerializationAttributes(): array + protected function addSerializationAttributes(Property|Method $property): self { - $attributes = parent::getSerializationAttributes(); - $attributes[] = new AttributeGenerator('Serializer\VirtualProperty'); - $attributes[] = new AttributeGenerator('Serializer\SerializedName', [ - AttributeGenerator::wrapString($this->field->getVarName()) + parent::addSerializationAttributes($property); + $property->addAttribute('JMS\Serializer\Annotation\VirtualProperty'); + $property->addAttribute('JMS\Serializer\Annotation\SerializedName', [ + $this->field->getVarName() ]); - return $attributes; + return $this; } protected function getDefaultSerializationGroups(): array @@ -32,65 +34,64 @@ protected function getFieldTypeDeclaration(): string return '?array'; } - protected function getFieldDefaultValueDeclaration(): string + protected function getFieldDefaultValueDeclaration(): Literal|string|null { - return 'null'; + return new Literal('null'); } - /** - * @inheritDoc - */ - public function getFieldGetter(): string - { - return ' - /** - * @return ' . $this->options['custom_form_class'] . '[] CustomForm array - */ -' . (new AttributeListGenerator($this->getSerializationAttributes()))->generate(4) . ' - public function ' . $this->field->getGetterName() . '(): array + public function addFieldGetter(ClassType $classType): self { - if (null === $this->' . $this->field->getVarName() . ') { - if (null !== $this->objectManager) { - $this->' . $this->field->getVarName() . ' = $this->objectManager - ->getRepository(' . $this->options['custom_form_class'] . '::class) - ->findByNodeAndFieldName( - $this->getNode(), - \'' . $this->field->getName() . '\' - ); - } else { - $this->' . $this->field->getVarName() . ' = []; - } - } - return $this->' . $this->field->getVarName() . '; - }' . PHP_EOL; + $method = $classType + ->addMethod($this->field->getGetterName()) + ->setReturnType('array') + ->setVisibility('public') + ->addComment('@return ' . $this->options['custom_form_class'] . '[] CustomForm array') + ; + $this->addSerializationAttributes($method); + + $method->setBody(<<{$this->field->getVarName()}) { + if (null !== \$this->objectManager) { + \$this->{$this->field->getVarName()} = \$this->objectManager + ->getRepository({$this->options['custom_form_class']}::class) + ->findByNodeAndFieldName( + \$this->getNode(), + '{$this->field->getName()}' + ); + } else { + \$this->{$this->field->getVarName()} = []; } +} +return \$this->{$this->field->getVarName()}; +EOF + ); - /** - * Generate PHP setter method block. - * - * @return string - */ - protected function getFieldSetter(): string - { - return ' - /** - * @param ' . $this->options['custom_form_class'] . ' $customForm - * - * @return $this - */ - public function add' . ucfirst($this->field->getVarName()) . '(' . $this->options['custom_form_class'] . ' $customForm): static + return $this; + } + + protected function addFieldSetter(ClassType $classType): self { - if (null !== $this->objectManager) { - $nodeCustomForm = new ' . $this->options['custom_form_proxy_class'] . '( - $this->getNode(), - $customForm - ); - $nodeCustomForm->setFieldName(\'' . $this->field->getName() . '\'); - $this->objectManager->persist($nodeCustomForm); - $this->getNode()->addCustomForm($nodeCustomForm); - $this->' . $this->field->getVarName() . ' = null; - } + $method = $classType + ->addMethod('add' . ucfirst($this->field->getVarName())) + ->setReturnType('static') + ->setVisibility('public') + ->addComment('@return $this') + ; + $method->addParameter('customForm')->setType($this->options['custom_form_class']); + $method->setBody(<<objectManager) { + \$nodeCustomForm = new {$this->options['custom_form_proxy_class']}( + \$this->getNode(), + \$customForm + ); + \$nodeCustomForm->setFieldName('{$this->field->getName()}'); + \$this->objectManager->persist(\$nodeCustomForm); + \$this->getNode()->addCustomForm(\$nodeCustomForm); + \$this->{$this->field->getVarName()} = null; +} +return \$this; +EOF + ); return $this; - }' . PHP_EOL; } } diff --git a/lib/EntityGenerator/src/Field/DocumentsFieldGenerator.php b/lib/EntityGenerator/src/Field/DocumentsFieldGenerator.php index be8732ef..ba30e45c 100644 --- a/lib/EntityGenerator/src/Field/DocumentsFieldGenerator.php +++ b/lib/EntityGenerator/src/Field/DocumentsFieldGenerator.php @@ -4,28 +4,28 @@ namespace RZ\Roadiz\EntityGenerator\Field; -use RZ\Roadiz\EntityGenerator\Attribute\AttributeGenerator; -use RZ\Roadiz\EntityGenerator\Attribute\AttributeListGenerator; +use Nette\PhpGenerator\ClassType; +use Nette\PhpGenerator\Literal; +use Nette\PhpGenerator\Method; +use Nette\PhpGenerator\Property; use Symfony\Component\String\UnicodeString; -class DocumentsFieldGenerator extends AbstractFieldGenerator +final class DocumentsFieldGenerator extends AbstractFieldGenerator { - protected function getSerializationAttributes(): array + protected function addSerializationAttributes(Property|Method $property): self { - $annotations = parent::getSerializationAttributes(); - $annotations[] = new AttributeGenerator('Serializer\VirtualProperty'); - $annotations[] = new AttributeGenerator('Serializer\SerializedName', [ - AttributeGenerator::wrapString($this->field->getVarName()) + parent::addSerializationAttributes($property); + $property->addAttribute('JMS\Serializer\Annotation\VirtualProperty'); + $property->addAttribute('JMS\Serializer\Annotation\SerializedName', [ + $this->field->getVarName() ]); - $annotations[] = new AttributeGenerator('Serializer\Type', [ - AttributeGenerator::wrapString( - 'array<' . - (new UnicodeString($this->options['document_class']))->trimStart('\\')->toString() . - '>' - ) + $property->addAttribute('JMS\Serializer\Annotation\Type', [ + 'array<' . + (new UnicodeString($this->options['document_class']))->trimStart('\\')->toString() . + '>' ]); - return $annotations; + return $this; } protected function getDefaultSerializationGroups(): array @@ -40,67 +40,63 @@ protected function getFieldTypeDeclaration(): string return '?array'; } - protected function getFieldDefaultValueDeclaration(): string + protected function getFieldDefaultValueDeclaration(): Literal|string|null { - return 'null'; + return new Literal('null'); } - /** - * @inheritDoc - */ - public function getFieldGetter(): string - { - return ' - /** - * @return ' . $this->options['document_class'] . '[] Documents array - */ -' . (new AttributeListGenerator($this->getSerializationAttributes()))->generate(4) . ' - public function ' . $this->field->getGetterName() . '(): array + public function addFieldGetter(ClassType $classType): self { - if (null === $this->' . $this->field->getVarName() . ') { - if (null !== $this->objectManager) { - $this->' . $this->field->getVarName() . ' = $this->objectManager - ->getRepository(' . $this->options['document_class'] . '::class) - ->findByNodeSourceAndFieldName( - $this, - \'' . $this->field->getName() . '\' - ); - } else { - $this->' . $this->field->getVarName() . ' = []; - } - } - return $this->' . $this->field->getVarName() . '; - }' . PHP_EOL; + $getter = $classType->addMethod($this->field->getGetterName()) + ->setReturnType('array') + ->addComment('@return ' . $this->options['document_class'] . '[]'); + $this->addSerializationAttributes($getter); + $getter->setBody(<<{$this->field->getVarName()}) { + if (null !== \$this->objectManager) { + \$this->{$this->field->getVarName()} = \$this->objectManager + ->getRepository({$this->options['document_class']}::class) + ->findByNodeSourceAndFieldName( + \$this, + '{$this->field->getName()}' + ); + } else { + \$this->{$this->field->getVarName()} = []; } +} +return \$this->{$this->field->getVarName()}; +EOF + ); - /** - * Generate PHP setter method block. - * - * @return string - */ - protected function getFieldSetter(): string - { - return ' - /** - * @param ' . $this->options['document_class'] . ' $document - * - * @return $this - */ - public function add' . ucfirst($this->field->getVarName()) . '(' . $this->options['document_class'] . ' $document): static + return $this; + } + + protected function addFieldSetter(ClassType $classType): self { - if (null !== $this->objectManager) { - $nodeSourceDocument = new ' . $this->options['document_proxy_class'] . '( - $this, - $document - ); - $nodeSourceDocument->setFieldName(\'' . $this->field->getName() . '\'); - if (!$this->hasNodesSourcesDocuments($nodeSourceDocument)) { - $this->objectManager->persist($nodeSourceDocument); - $this->addDocumentsByFields($nodeSourceDocument); - $this->' . $this->field->getVarName() . ' = null; - } - } + $setter = $classType->addMethod('add' . ucfirst($this->field->getVarName())) + ->setReturnType('static') + ->addComment('@return $this') + ->setPublic(); + + $setter->addParameter('document') + ->setType($this->options['document_class']); + $setter->setBody(<<objectManager) { + return \$this; +} +\$nodeSourceDocument = new {$this->options['document_proxy_class']}( + \$this, + \$document +); +\$nodeSourceDocument->setFieldName('{$this->field->getName()}'); +if (!\$this->hasNodesSourcesDocuments(\$nodeSourceDocument)) { + \$this->objectManager->persist(\$nodeSourceDocument); + \$this->addDocumentsByFields(\$nodeSourceDocument); + \$this->{$this->field->getVarName()} = null; +} +return \$this; +PHP + ); return $this; - }' . PHP_EOL; } } diff --git a/lib/EntityGenerator/src/Field/ManyToManyFieldGenerator.php b/lib/EntityGenerator/src/Field/ManyToManyFieldGenerator.php index 09039bb6..de2cb745 100644 --- a/lib/EntityGenerator/src/Field/ManyToManyFieldGenerator.php +++ b/lib/EntityGenerator/src/Field/ManyToManyFieldGenerator.php @@ -4,14 +4,25 @@ namespace RZ\Roadiz\EntityGenerator\Field; -use RZ\Roadiz\EntityGenerator\Attribute\AttributeGenerator; +use Nette\PhpGenerator\ClassType; +use Nette\PhpGenerator\Literal; +use Nette\PhpGenerator\Property; use Symfony\Component\String\UnicodeString; -class ManyToManyFieldGenerator extends AbstractConfigurableFieldGenerator +final class ManyToManyFieldGenerator extends AbstractConfigurableFieldGenerator { - protected function getFieldAttributes(bool $exclude = false): array + protected function getFieldProperty(ClassType $classType): Property { - $attributes = parent::getFieldAttributes($exclude); + return $classType + ->addProperty($this->field->getVarName()) + ->setPrivate() + ->setType($this->getFieldTypeDeclaration()); + } + + + protected function addFieldAttributes(Property $property, bool $exclude = false): self + { + parent::addFieldAttributes($property, $exclude); /* * Many Users have Many Groups. @@ -31,102 +42,96 @@ protected function getFieldAttributes(bool $exclude = false): array ; $entityB = $this->field->getName(); $joinColumnParams = [ - 'name' => AttributeGenerator::wrapString($entityA . '_id'), - 'referencedColumnName' => AttributeGenerator::wrapString('id'), - 'onDelete' => AttributeGenerator::wrapString('CASCADE') + 'name' => $entityA . '_id', + 'referencedColumnName' => 'id', + 'onDelete' => 'CASCADE' ]; $inverseJoinColumns = [ - 'name' => AttributeGenerator::wrapString($entityB . '_id'), - 'referencedColumnName' => AttributeGenerator::wrapString('id'), - 'onDelete' => AttributeGenerator::wrapString('CASCADE') + 'name' => $entityB . '_id', + 'referencedColumnName' => 'id', + 'onDelete' => 'CASCADE' ]; - $attributes[] = new AttributeGenerator('ORM\ManyToMany', [ - 'targetEntity' => $this->getFullyQualifiedClassName() . '::class' + $property->addAttribute('Doctrine\ORM\Mapping\ManyToMany', [ + 'targetEntity' => new Literal($this->getFullyQualifiedClassName() . '::class') ]); - $attributes[] = new AttributeGenerator('ORM\JoinTable', [ - 'name' => AttributeGenerator::wrapString($entityA . '_' . $entityB) + $property->addAttribute('Doctrine\ORM\Mapping\JoinTable', [ + 'name' => $entityA . '_' . $entityB ]); - $attributes[] = new AttributeGenerator('ORM\JoinColumn', $joinColumnParams); - $attributes[] = new AttributeGenerator('ORM\InverseJoinColumn', $inverseJoinColumns); + $property->addAttribute('Doctrine\ORM\Mapping\JoinColumn', $joinColumnParams); + $property->addAttribute('Doctrine\ORM\Mapping\InverseJoinColumn', $inverseJoinColumns); if (count($this->configuration['orderBy']) > 0) { // use default order for Collections $orderBy = []; foreach ($this->configuration['orderBy'] as $order) { - $orderBy[] = AttributeGenerator::wrapString($order['field']) . - ' => ' . - AttributeGenerator::wrapString($order['direction']); + $orderBy[$order['field']] = $order['direction']; } - $attributes[] = new AttributeGenerator('ORM\OrderBy', [ - 0 => '[' . implode(', ', $orderBy) . ']' + $property->addAttribute('Doctrine\ORM\Mapping\OrderBy', [ + $orderBy ]); } if ($this->options['use_api_platform_filters'] === true) { - $attributes[] = new AttributeGenerator('ApiFilter', [ - 0 => 'OrmFilter\SearchFilter::class', - 'strategy' => AttributeGenerator::wrapString('exact') + $property->addAttribute('ApiPlatform\Metadata\ApiFilter', [ + 0 => new Literal('\ApiPlatform\Doctrine\Orm\Filter\SearchFilter::class'), + 'strategy' => 'exact' ]); } - return [ - ...$attributes, - ...$this->getSerializationAttributes() - ]; + $this->addSerializationAttributes($property); + + return $this; } - /** - * @inheritDoc - */ - public function getFieldAnnotation(): string + public function addFieldAnnotation(Property $property): self { - return ' - /** - *' . implode(PHP_EOL . static::ANNOTATION_PREFIX, $this->getFieldAutodoc()) . ' - * @var CollectiongetFullyQualifiedClassName() . '> - */' . PHP_EOL; + $this->addFieldAutodoc($property); + $property->addComment( + '@var \Doctrine\Common\Collections\CollectiongetFullyQualifiedClassName() . '>' + ); + return $this; } protected function getFieldTypeDeclaration(): string { - return 'Collection'; + return '\Doctrine\Common\Collections\Collection'; } - /** - * @inheritDoc - */ - public function getFieldGetter(): string + public function addFieldGetter(ClassType $classType): self { - return ' - /** - * @return CollectiongetFullyQualifiedClassName() . '> - */ - public function ' . $this->field->getGetterName() . '(): Collection - { - return $this->' . $this->field->getVarName() . '; - }' . PHP_EOL; + $classType->addMethod($this->field->getGetterName()) + ->setReturnType('\Doctrine\Common\Collections\Collection') + ->setPublic() + ->setBody('return $this->' . $this->field->getVarName() . ';') + ->addComment('@return \Doctrine\Common\Collections\CollectiongetFullyQualifiedClassName() . '>'); + return $this; } - /** - * @inheritDoc - */ - public function getFieldSetter(): string + public function addFieldSetter(ClassType $classType): self { - return ' - /** - * @param CollectiongetFullyQualifiedClassName() . '>|' . $this->getFullyQualifiedClassName() . '[] $' . $this->field->getVarName() . ' - * @return $this - */ - public function ' . $this->field->getSetterName() . '(Collection|array $' . $this->field->getVarName() . '): static - { - if ($' . $this->field->getVarName() . ' instanceof \Doctrine\Common\Collections\Collection) { - $this->' . $this->field->getVarName() . ' = $' . $this->field->getVarName() . '; - } else { - $this->' . $this->field->getVarName() . ' = new \Doctrine\Common\Collections\ArrayCollection($' . $this->field->getVarName() . '); - } + $setter = $classType->addMethod($this->field->getSetterName()) + ->setReturnType('static') + ->addComment( + '@param \Doctrine\Common\Collections\CollectiongetFullyQualifiedClassName() . + '>|array<' . $this->getFullyQualifiedClassName() . '> $' . $this->field->getVarName() + ) + ->addComment('@return $this') + ->setPublic(); + + $setter->addParameter($this->field->getVarName()) + ->setType('\Doctrine\Common\Collections\Collection|array'); + + $setter->setBody(<<field->getVarName()} instanceof \Doctrine\Common\Collections\Collection) { + \$this->{$this->field->getVarName()} = \${$this->field->getVarName()}; +} else { + \$this->{$this->field->getVarName()} = new \Doctrine\Common\Collections\ArrayCollection(\${$this->field->getVarName()}); +} +return \$this; +PHP + ); return $this; - }' . PHP_EOL; } protected function isExcludingFieldFromJmsSerialization(): bool diff --git a/lib/EntityGenerator/src/Field/ManyToOneFieldGenerator.php b/lib/EntityGenerator/src/Field/ManyToOneFieldGenerator.php index 44cd42ef..6726efb6 100644 --- a/lib/EntityGenerator/src/Field/ManyToOneFieldGenerator.php +++ b/lib/EntityGenerator/src/Field/ManyToOneFieldGenerator.php @@ -4,40 +4,40 @@ namespace RZ\Roadiz\EntityGenerator\Field; -use RZ\Roadiz\EntityGenerator\Attribute\AttributeGenerator; +use Nette\PhpGenerator\ClassType; +use Nette\PhpGenerator\Literal; +use Nette\PhpGenerator\Property; -class ManyToOneFieldGenerator extends AbstractConfigurableFieldGenerator +final class ManyToOneFieldGenerator extends AbstractConfigurableFieldGenerator { - protected function getFieldAttributes(bool $exclude = false): array + protected function addFieldAttributes(Property $property, bool $exclude = false): self { - $attributes = parent::getFieldAttributes($exclude); + parent::addFieldAttributes($property, $exclude); /* * Many Users have One Address. - * @ORM\ManyToOne(targetEntity="Address") - * @ORM\JoinColumn(name="address_id", referencedColumnName="id", onDelete="SET NULL") + * @\Doctrine\ORM\Mapping\ManyToOne(targetEntity="Address") + * @\Doctrine\ORM\Mapping\JoinColumn(name="address_id", referencedColumnName="id", onDelete="SET NULL") */ $ormParams = [ - 'name' => AttributeGenerator::wrapString($this->field->getName() . '_id'), - 'referencedColumnName' => AttributeGenerator::wrapString('id'), - 'onDelete' => AttributeGenerator::wrapString('SET NULL'), + 'name' => $this->field->getName() . '_id', + 'referencedColumnName' => 'id', + 'onDelete' => 'SET NULL', ]; - $attributes[] = new AttributeGenerator('ORM\ManyToOne', [ - 'targetEntity' => $this->getFullyQualifiedClassName() . '::class' + $property->addAttribute('Doctrine\ORM\Mapping\ManyToOne', [ + 'targetEntity' => new Literal($this->getFullyQualifiedClassName() . '::class') ]); - $attributes[] = new AttributeGenerator('ORM\JoinColumn', $ormParams); + $property->addAttribute('Doctrine\ORM\Mapping\JoinColumn', $ormParams); if ($this->options['use_api_platform_filters'] === true) { - $attributes[] = new AttributeGenerator('ApiFilter', [ - 0 => 'OrmFilter\SearchFilter::class', - 'strategy' => AttributeGenerator::wrapString('exact') + $property->addAttribute('ApiPlatform\Metadata\ApiFilter', [ + 0 => new Literal('\ApiPlatform\Doctrine\Orm\Filter\SearchFilter::class'), + 'strategy' => 'exact' ]); } - return [ - ...$attributes, - ...$this->getSerializationAttributes() - ]; + $this->addSerializationAttributes($property); + return $this; } protected function isExcludingFieldFromJmsSerialization(): bool @@ -45,16 +45,10 @@ protected function isExcludingFieldFromJmsSerialization(): bool return false; } - /** - * @inheritDoc - */ - public function getFieldAnnotation(): string + public function addFieldAnnotation(Property $property): self { - return ' - /** - *' . implode(PHP_EOL . static::ANNOTATION_PREFIX, $this->getFieldAutodoc()) . ' - * @var ' . $this->getFullyQualifiedClassName() . '|null - */' . PHP_EOL; + $this->addFieldAutodoc($property); + return $this; } protected function getFieldTypeDeclaration(): string @@ -62,41 +56,38 @@ protected function getFieldTypeDeclaration(): string return '?' . $this->getFullyQualifiedClassName(); } - protected function getFieldDefaultValueDeclaration(): string + protected function getFieldDefaultValueDeclaration(): Literal|string|null { - return 'null'; + return new Literal('null'); } - /** - * @inheritDoc - */ - public function getFieldGetter(): string + public function addFieldGetter(ClassType $classType): self { - return ' - /** - * @return ' . $this->getFullyQualifiedClassName() . '|null - */ - public function ' . $this->field->getGetterName() . '(): ?' . $this->getFullyQualifiedClassName() . ' - { - return $this->' . $this->field->getVarName() . '; - }' . PHP_EOL; + $classType->addMethod($this->field->getGetterName()) + ->setReturnType($this->getFieldTypeDeclaration()) + ->setPublic() + ->setBody(<<{$this->field->getVarName()}; +PHP + ); + return $this; } - /** - * @inheritDoc - */ - public function getFieldSetter(): string - { - return ' - /** - * @param ' . $this->getFullyQualifiedClassName() . '|null $' . $this->field->getVarName() . ' - * @return $this - */ - public function ' . $this->field->getSetterName() . '(?' . $this->getFullyQualifiedClassName() . ' $' . $this->field->getVarName() . ' = null): static + public function addFieldSetter(ClassType $classType): self { - $this->' . $this->field->getVarName() . ' = $' . $this->field->getVarName() . '; + $setter = $classType->addMethod($this->field->getSetterName()) + ->setReturnType('static') + ->addComment('@return $this') + ->setPublic(); + $setter->addParameter($this->field->getVarName()) + ->setType($this->getFieldTypeDeclaration()) + ->setNullable(); + $setter->setBody(<<{$this->field->getVarName()} = \${$this->field->getVarName()}; +return \$this; +PHP + ); return $this; - }' . PHP_EOL; } } diff --git a/lib/EntityGenerator/src/Field/NodesFieldGenerator.php b/lib/EntityGenerator/src/Field/NodesFieldGenerator.php index 9f11d150..e93fb63b 100644 --- a/lib/EntityGenerator/src/Field/NodesFieldGenerator.php +++ b/lib/EntityGenerator/src/Field/NodesFieldGenerator.php @@ -4,54 +4,45 @@ namespace RZ\Roadiz\EntityGenerator\Field; +use Nette\PhpGenerator\ClassType; +use Nette\PhpGenerator\Literal; +use Nette\PhpGenerator\Method; +use Nette\PhpGenerator\Property; use RZ\Roadiz\Contracts\NodeType\NodeTypeFieldInterface; use RZ\Roadiz\Contracts\NodeType\NodeTypeResolverInterface; -use RZ\Roadiz\EntityGenerator\Attribute\AttributeGenerator; -use RZ\Roadiz\EntityGenerator\Attribute\AttributeListGenerator; use Symfony\Component\String\UnicodeString; -class NodesFieldGenerator extends AbstractFieldGenerator +final class NodesFieldGenerator extends AbstractFieldGenerator { - private NodeTypeResolverInterface $nodeTypeResolver; - public function __construct( + private readonly NodeTypeResolverInterface $nodeTypeResolver, NodeTypeFieldInterface $field, - NodeTypeResolverInterface $nodeTypeResolver, DefaultValuesResolverInterface $defaultValuesResolver, - array $options = [] + array $options = [], ) { parent::__construct($field, $defaultValuesResolver, $options); - $this->nodeTypeResolver = $nodeTypeResolver; } - /** - * Generate PHP code for current doctrine field. - * - * @return string - */ - public function getField(): string + public function addField(ClassType $classType): void { - return $this->getFieldGetter() . - $this->getFieldAlternativeGetter() . - $this->getFieldSetter() . PHP_EOL; + $this->addFieldGetter($classType); + $this->addFieldSetter($classType); } - protected function getSerializationAttributes(): array + protected function addSerializationAttributes(Property|Method $property): self { - $annotations = parent::getSerializationAttributes(); - $annotations[] = new AttributeGenerator('Serializer\VirtualProperty'); - $annotations[] = new AttributeGenerator('Serializer\SerializedName', [ - AttributeGenerator::wrapString($this->field->getVarName()) + parent::addSerializationAttributes($property); + $property->addAttribute('JMS\Serializer\Annotation\VirtualProperty'); + $property->addAttribute('JMS\Serializer\Annotation\SerializedName', [ + $this->field->getVarName() ]); - $annotations[] = new AttributeGenerator('Serializer\Type', [ - AttributeGenerator::wrapString( - 'array<' . - (new UnicodeString($this->options['parent_class']))->trimStart('\\')->toString() . - '>' - ) + $property->addAttribute('JMS\Serializer\Annotation\Type', [ + 'array<' . + (new UnicodeString($this->options['parent_class']))->trimStart('\\')->toString() . + '>' ]); - return $annotations; + return $this; } protected function getDefaultSerializationGroups(): array @@ -98,69 +89,57 @@ protected function getRepositoryClass(): string return $this->options['parent_class']; } - /** - * @inheritDoc - */ - public function getFieldGetter(): string - { - $autodoc = ''; - $fieldAutoDoc = $this->getFieldAutodoc(); - if (!empty($fieldAutoDoc)) { - $autodoc = PHP_EOL . - static::ANNOTATION_PREFIX . - implode(PHP_EOL . static::ANNOTATION_PREFIX, $fieldAutoDoc); - } - - return ' - /** - * ' . $this->getFieldSourcesName() . ' NodesSources direct field buffer. - * (Virtual field, this var is a buffer) - *' . $autodoc . ' - * @var ' . $this->getRepositoryClass() . '[]|null - */ -' . (new AttributeListGenerator( - $this->getFieldAttributes($this->isExcludingFieldFromJmsSerialization()) - ))->generate(4) . ' - private ?array $' . $this->getFieldSourcesName() . ' = null; - - /** - * @return ' . $this->getRepositoryClass() . '[] ' . $this->field->getVarName() . ' nodes-sources array - */ -' . (new AttributeListGenerator($this->getSerializationAttributes()))->generate(4) . ' - public function ' . $this->field->getGetterName() . 'Sources(): array + public function addFieldGetter(ClassType $classType): self { - if (null === $this->' . $this->getFieldSourcesName() . ') { - if (null !== $this->objectManager) { - $this->' . $this->getFieldSourcesName() . ' = $this->objectManager - ->getRepository(' . $this->getRepositoryClass() . '::class) - ->findByNodesSourcesAndFieldNameAndTranslation( - $this, - \'' . $this->field->getName() . '\' - ); - } else { - $this->' . $this->getFieldSourcesName() . ' = []; - } - } - return $this->' . $this->getFieldSourcesName() . '; - }' . PHP_EOL; + $property = $classType->addProperty($this->getFieldSourcesName()) + ->setType('?array') + ->setPrivate() + ->setValue(null) + ->addComment($this->getFieldSourcesName() . ' NodesSources direct field buffer.') + ->addComment('@var ' . $this->getRepositoryClass() . '[]|null'); + + $this->addFieldAutodoc($property); + $this->addFieldAttributes($property, $this->isExcludingFieldFromJmsSerialization()); + + + $getter = $classType->addMethod($this->field->getGetterName() . 'Sources') + ->setReturnType('array') + ->addComment('@return ' . $this->getRepositoryClass() . '[]') + ->setPublic(); + $this->addSerializationAttributes($getter); + $getter->setBody(<<{$this->getFieldSourcesName()}) { + if (null !== \$this->objectManager) { + \$this->{$this->getFieldSourcesName()} = \$this->objectManager + ->getRepository({$this->getRepositoryClass()}::class) + ->findByNodesSourcesAndFieldNameAndTranslation( + \$this, + '{$this->field->getName()}' + ); + } else { + \$this->{$this->getFieldSourcesName()} = []; + } +} +return \$this->{$this->getFieldSourcesName()}; +PHP + ); + return $this; } - /** - * @inheritDoc - */ - public function getFieldSetter(): string - { - return ' - /** - * @param ' . $this->getRepositoryClass() . '[]|null $' . $this->getFieldSourcesName() . ' - * - * @return $this - */ - public function ' . $this->field->getSetterName() . 'Sources(?array $' . $this->getFieldSourcesName() . '): static + public function addFieldSetter(ClassType $classType): self { - $this->' . $this->getFieldSourcesName() . ' = $' . $this->getFieldSourcesName() . '; - + $setter = $classType->addMethod($this->field->getSetterName() . 'Sources') + ->setReturnType('static') + ->addComment('@param ' . $this->getRepositoryClass() . '[]|null $' . $this->getFieldSourcesName()) + ->addComment('@return $this') + ->setPublic(); + $setter->addParameter($this->getFieldSourcesName()) + ->setType('?array'); + $setter->setBody(<<{$this->getFieldSourcesName()} = \${$this->getFieldSourcesName()}; +return \$this; +PHP + ); return $this; - }' . PHP_EOL; } } diff --git a/lib/EntityGenerator/src/Field/NonVirtualFieldGenerator.php b/lib/EntityGenerator/src/Field/NonVirtualFieldGenerator.php index 9a9df5e8..d9bcb690 100644 --- a/lib/EntityGenerator/src/Field/NonVirtualFieldGenerator.php +++ b/lib/EntityGenerator/src/Field/NonVirtualFieldGenerator.php @@ -4,24 +4,29 @@ namespace RZ\Roadiz\EntityGenerator\Field; -use RZ\Roadiz\EntityGenerator\Attribute\AttributeGenerator; +use Nette\PhpGenerator\ClassType; +use Nette\PhpGenerator\Literal; +use Nette\PhpGenerator\Property; class NonVirtualFieldGenerator extends AbstractFieldGenerator { /** * Generate PHP annotation block for Doctrine table indexes. - * - * @return AttributeGenerator|null */ - public function getFieldIndex(): ?AttributeGenerator + public function addFieldIndex(ClassType $classType): self { if ($this->field->isIndexed()) { - return new AttributeGenerator('ORM\Index', [ - 'columns' => '[' . AttributeGenerator::wrapString($this->field->getName()) . ']' - ]); + $classType->addAttribute( + 'Doctrine\ORM\Mapping\Index', + [ + 'columns' => [ + $this->field->getName() + ] + ] + ); } - return null; + return $this; } /** @@ -57,9 +62,9 @@ protected function isExcludingFieldFromJmsSerialization(): bool return false; } - protected function getFieldAttributes(bool $exclude = false): array + protected function addFieldAttributes(Property $property, bool $exclude = false): self { - $attributes = parent::getFieldAttributes($exclude); + parent::addFieldAttributes($property, $exclude); /* * ?string $name = null, @@ -77,9 +82,9 @@ protected function getFieldAttributes(bool $exclude = false): array * ?string $generated = null */ $ormParams = [ - 'name' => AttributeGenerator::wrapString($this->field->getName()), - 'type' => AttributeGenerator::wrapString($this->getDoctrineType()), - 'nullable' => 'true', + 'name' => $this->field->getName(), + 'type' => $this->getDoctrineType(), + 'nullable' => true, ]; $fieldLength = $this->getFieldLength(); @@ -91,111 +96,81 @@ protected function getFieldAttributes(bool $exclude = false): array $ormParams['precision'] = 18; $ormParams['scale'] = 3; } elseif ($this->field->isBool()) { - $ormParams['nullable'] = 'false'; - $ormParams['options'] = '["default" => false]'; + $ormParams['nullable'] = false; + $ormParams['options'] = [ + 'default' => false + ]; } - $attributes[] = new AttributeGenerator('Gedmo\Versioned'); - $attributes[] = new AttributeGenerator('ORM\Column', $ormParams); + $property->addAttribute('Gedmo\Mapping\Annotation\Versioned'); + $property->addAttribute('Doctrine\ORM\Mapping\Column', $ormParams); - if (empty($this->getFieldAlternativeGetter()) && !empty($this->getSerializationAttributes())) { - return [ - ...$attributes, - ...$this->getSerializationAttributes() - ]; + if (!$this->hasFieldAlternativeGetter() && $this->hasSerializationAttributes()) { + $this->addSerializationAttributes($property); } - return $attributes; + return $this; } - - /** - * @inheritDoc - */ - public function getFieldAnnotation(): string + public function addFieldAnnotation(Property $property): self { - $autodoc = ''; - if (!empty($this->getFieldAutodoc())) { - $autodoc = PHP_EOL . - static::ANNOTATION_PREFIX . - implode(PHP_EOL . static::ANNOTATION_PREFIX, $this->getFieldAutodoc()); - } - - return ' - /**' . $autodoc . ' - */' . PHP_EOL; + $this->addFieldAutodoc($property); + return $this; } protected function getFieldTypeDeclaration(): string { - switch (true) { - case $this->field->isBool(): - return 'bool'; - case $this->field->isMultiple(): - return '?array'; - case $this->field->isInteger(): - case $this->field->isDecimal(): - return 'int|float|null'; - case $this->field->isColor(): - case $this->field->isEmail(): - case $this->field->isString(): - case $this->field->isCountry(): - case $this->field->isMarkdown(): - case $this->field->isText(): - case $this->field->isRichText(): - case $this->field->isEnum(): - return '?string'; - case $this->field->isDateTime(): - case $this->field->isDate(): - return '?\DateTime'; - default: - return ''; - } + return match (true) { + $this->field->isBool() => 'bool', + $this->field->isMultiple() => '?array', + $this->field->isInteger(), + $this->field->isDecimal() => 'int|float|null', + $this->field->isColor(), + $this->field->isEmail(), + $this->field->isString(), + $this->field->isCountry(), + $this->field->isMarkdown(), + $this->field->isText(), + $this->field->isRichText(), + $this->field->isEnum() => '?string', + $this->field->isDateTime(), + $this->field->isDate() => '?\DateTime', + default => 'mixed', + }; } - protected function getFieldDefaultValueDeclaration(): string + protected function getFieldDefaultValueDeclaration(): Literal|string|null { - switch (true) { - case $this->field->isBool(): - return 'false'; - default: - return 'null'; - } + return match (true) { + $this->field->isBool() => new Literal('false'), + default => new Literal('null'), + }; } - /** - * @inheritDoc - */ - public function getFieldGetter(): string + public function addFieldGetter(ClassType $classType): self { $type = $this->getFieldTypeDeclaration(); - if (empty($type)) { - $docType = 'mixed'; - $typeHint = ''; - } else { - $docType = $this->toPhpDocType($type); - $typeHint = ': ' . $type; - } - $assignation = '$this->' . $this->field->getVarName(); + $method = $classType->addMethod($this->field->getGetterName()) + ->setPublic() + ->setReturnType($type) + ->addComment('@return ' . $this->toPhpDocType($type)); if ($this->field->isMultiple()) { - $assignation = sprintf('null !== %s ? array_values(%s) : null', $assignation, $assignation); + $method->setBody( + 'return null !== $this->' . + $this->field->getVarName() . ' ? array_values($this->' . $this->field->getVarName() . ') : null;' + ); + } else { + $method->setBody('return $this->' . $this->field->getVarName() . ';'); } - return ' - /** - * @return ' . $docType . ' - */ - public function ' . $this->field->getGetterName() . '()' . $typeHint . ' - { - return ' . $assignation . '; - }' . PHP_EOL; + return $this; } /** * @inheritDoc */ - public function getFieldSetter(): string + public function addFieldSetter(ClassType $classType): self { $assignation = '$' . $this->field->getVarName(); $nullable = true; @@ -203,7 +178,7 @@ public function getFieldSetter(): string switch (true) { case $this->field->isBool(): - $casting = '(boolean) '; + $casting = '(bool) '; $nullable = false; break; case $this->field->isInteger(): @@ -222,13 +197,6 @@ public function getFieldSetter(): string } $type = $this->getFieldTypeDeclaration(); - if (empty($type)) { - $docType = 'mixed'; - $typeHint = ''; - } else { - $docType = $this->toPhpDocType($type); - $typeHint = $type . ' '; - } if ($nullable && !empty($casting)) { $assignation = '$this->' . $this->field->getVarName() . ' = null !== $' . $this->field->getVarName() . ' ? @@ -238,17 +206,14 @@ public function getFieldSetter(): string $assignation = '$this->' . $this->field->getVarName() . ' = ' . $assignation . ';'; } - return ' - /** - * @param ' . $docType . ' $' . $this->field->getVarName() . ' - * - * @return $this - */ - public function ' . $this->field->getSetterName() . '(' . $typeHint . '$' . $this->field->getVarName() . '): static - { - ' . $assignation . ' + $method = $classType->addMethod($this->field->getSetterName())->setPublic(); + $method->setReturnType('static')->addComment('@return $this'); + $method->addParameter($this->field->getVarName())->setType($type); + $method + ->addBody($assignation) + ->addBody('return $this;') + ; return $this; - }' . PHP_EOL; } } diff --git a/lib/EntityGenerator/src/Field/ProxiedManyToManyFieldGenerator.php b/lib/EntityGenerator/src/Field/ProxiedManyToManyFieldGenerator.php index ccfd13ea..6a8fa90a 100644 --- a/lib/EntityGenerator/src/Field/ProxiedManyToManyFieldGenerator.php +++ b/lib/EntityGenerator/src/Field/ProxiedManyToManyFieldGenerator.php @@ -4,52 +4,55 @@ namespace RZ\Roadiz\EntityGenerator\Field; -use RZ\Roadiz\EntityGenerator\Attribute\AttributeGenerator; -use RZ\Roadiz\EntityGenerator\Attribute\AttributeListGenerator; +use Nette\PhpGenerator\ClassType; +use Nette\PhpGenerator\Literal; +use Nette\PhpGenerator\Method; +use Nette\PhpGenerator\Property; use Symfony\Component\String\UnicodeString; -class ProxiedManyToManyFieldGenerator extends AbstractConfigurableFieldGenerator +final class ProxiedManyToManyFieldGenerator extends AbstractConfigurableFieldGenerator { - protected function getSerializationAttributes(): array + protected function addSerializationAttributes(Property|Method $property): self { - $annotations = parent::getSerializationAttributes(); - if (!$this->excludeFromSerialization()) { - $annotations[] = new AttributeGenerator('Serializer\VirtualProperty'); - $annotations[] = new AttributeGenerator('Serializer\SerializedName', [ - AttributeGenerator::wrapString($this->field->getVarName()) - ]); - $annotations[] = new AttributeGenerator('SymfonySerializer\SerializedName', [ - 'serializedName' => AttributeGenerator::wrapString($this->field->getVarName()) - ]); - $annotations[] = new AttributeGenerator('SymfonySerializer\Groups', [ - $this->getSerializationGroups() + parent::addSerializationAttributes($property); + if ($this->excludeFromSerialization()) { + return $this; + } + + $property->addAttribute('JMS\Serializer\Annotation\VirtualProperty'); + $property->addAttribute('JMS\Serializer\Annotation\SerializedName', [ + $this->field->getVarName() + ]); + $property->addAttribute('Symfony\Component\Serializer\Attribute\SerializedName', [ + 'serializedName' => $this->field->getVarName() + ]); + $property->addAttribute('Symfony\Component\Serializer\Attribute\Groups', [ + $this->getSerializationGroups() + ]); + if ($this->getSerializationMaxDepth() > 0) { + $property->addAttribute('Symfony\Component\Serializer\Attribute\MaxDepth', [ + $this->getSerializationMaxDepth() ]); - if ($this->getSerializationMaxDepth() > 0) { - $annotations[] = new AttributeGenerator('SymfonySerializer\MaxDepth', [ - $this->getSerializationMaxDepth() - ]); - } } - return $annotations; + return $this; } /** * Generate PHP property declaration block. */ - protected function getFieldDeclaration(): string + protected function getFieldProperty(ClassType $classType): Property { - /* - * Buffer var to get referenced entities (documents, nodes, cforms, doctrine entities) - */ - return ' private Collection $' . $this->getProxiedVarName() . ';' . PHP_EOL; + return $classType + ->addProperty($this->getProxiedVarName()) + ->setPrivate() + ->addComment('Buffer var to get referenced entities (documents, nodes, cforms, doctrine entities)') + ->setType('\Doctrine\Common\Collections\Collection'); } - protected function getFieldAttributes(bool $exclude = false): array + protected function addFieldAttributes(Property $property, bool $exclude = false): self { - $attributes = []; - - $attributes[] = new AttributeGenerator('Serializer\Exclude'); - $attributes[] = new AttributeGenerator('SymfonySerializer\Ignore'); + $property->addAttribute('JMS\Serializer\Annotation\Exclude'); + $property->addAttribute('Symfony\Component\Serializer\Attribute\Ignore'); /* * Many Users have Many Groups. @@ -59,113 +62,109 @@ protected function getFieldAttributes(bool $exclude = false): array * inverseJoinColumns={@JoinColumn(name="group_id", referencedColumnName="id")} */ $ormParams = [ - 'targetEntity' => '\\' . trim($this->getProxyClassname(), '\\') . '::class', - 'mappedBy' => AttributeGenerator::wrapString($this->configuration['proxy']['self']), - 'orphanRemoval' => 'true', - 'cascade' => '["persist", "remove"]' + 'targetEntity' => new Literal('\\' . trim($this->getProxyClassname(), '\\') . '::class'), + 'mappedBy' => $this->configuration['proxy']['self'], + 'orphanRemoval' => true, + 'cascade' => ['persist', 'remove'] ]; - $attributes[] = new AttributeGenerator('ORM\OneToMany', $ormParams); + $property->addAttribute('Doctrine\ORM\Mapping\OneToMany', $ormParams); if (isset($this->configuration['proxy']['orderBy']) && count($this->configuration['proxy']['orderBy']) > 0) { // use default order for Collections $orderBy = []; foreach ($this->configuration['proxy']['orderBy'] as $order) { - $orderBy[] = AttributeGenerator::wrapString($order['field']) . - ' => ' . - AttributeGenerator::wrapString($order['direction']); + $orderBy[$order['field']] = $order['direction']; } - $attributes[] = new AttributeGenerator('ORM\OrderBy', [ - 0 => '[' . implode(', ', $orderBy) . ']' + $property->addAttribute('Doctrine\ORM\Mapping\OrderBy', [ + $orderBy ]); } - return $attributes; - } - - - /** - * @inheritDoc - */ - public function getFieldAnnotation(): string - { - return ' - /** - * ' . $this->field->getLabel() . ' - * - * @var CollectiongetProxyClassname() . '> - */' . PHP_EOL; + return $this; } - /** - * @inheritDoc - */ - public function getFieldGetter(): string - { - return ' - /** - * @return CollectiongetProxyClassname() . '> - */ - public function ' . $this->getProxiedGetterName() . '(): Collection + public function addFieldAnnotation(Property $property): self { - return $this->' . $this->getProxiedVarName() . '; + $property->addComment($this->field->getLabel() . '.'); + $property->addComment('@var \Doctrine\Common\Collections\CollectiongetProxyClassname() . '>'); + return $this; } - /** - * @return Collection - */ -' . (new AttributeListGenerator($this->getSerializationAttributes()))->generate(4) . ' - public function ' . $this->field->getGetterName() . '(): Collection + public function addFieldGetter(ClassType $classType): self { - return $this->' . $this->getProxiedVarName() . '->map(function (' . $this->getProxyClassname() . ' $proxyEntity) { - return $proxyEntity->' . $this->getProxyRelationGetterName() . '(); - }); - }' . PHP_EOL; - } + $classType->addMethod($this->getProxiedGetterName()) + ->setReturnType('\Doctrine\Common\Collections\Collection') + ->setPublic() + ->setBody('return $this->' . $this->getProxiedVarName() . ';') + ->addComment('@return \Doctrine\Common\Collections\CollectiongetProxyClassname() . '>'); - /** - * @inheritDoc - */ - public function getFieldSetter(): string - { - return ' - /** - * @param Collection $' . $this->getProxiedVarName() . ' - * @Serializer\VirtualProperty() - * @return $this - */ - public function ' . $this->getProxiedSetterName() . '(Collection $' . $this->getProxiedVarName() . '): static - { - $this->' . $this->getProxiedVarName() . ' = $' . $this->getProxiedVarName() . '; + // Real getter + $getter = $classType->addMethod($this->field->getGetterName()) + ->setPublic() + ->setReturnType('array'); + $this->addSerializationAttributes($getter); + $getter->setBody(<<{$this->getProxiedVarName()}->map(function ({$this->getProxyClassname()} \$proxyEntity) { + return \$proxyEntity->{$this->getProxyRelationGetterName()}(); +})->getValues(); +EOF + ); return $this; } - /** - * @param Collection|array|null $' . $this->field->getVarName() . ' - * @return $this - */ - public function ' . $this->field->getSetterName() . '(Collection|array|null $' . $this->field->getVarName() . ' = null): static - { - foreach ($this->' . $this->getProxiedGetterName() . '() as $item) { - $item->' . $this->getProxySelfSetterName() . '(null); - } - $this->' . $this->getProxiedVarName() . '->clear(); - if (null !== $' . $this->field->getVarName() . ') { - $position = 0; - foreach ($' . $this->field->getVarName() . ' as $single' . ucwords($this->field->getVarName()) . ') { - $proxyEntity = new ' . $this->getProxyClassname() . '(); - $proxyEntity->' . $this->getProxySelfSetterName() . '($this); - if ($proxyEntity instanceof \RZ\Roadiz\Core\AbstractEntities\PositionedInterface) { - $proxyEntity->setPosition(++$position); - } - $proxyEntity->' . $this->getProxyRelationSetterName() . '($single' . ucwords($this->field->getVarName()) . '); - $this->' . $this->getProxiedVarName() . '->add($proxyEntity); - $this->objectManager->persist($proxyEntity); - } + + public function addFieldSetter(ClassType $classType): self + { + $proxySetter = $classType->addMethod($this->getProxiedSetterName()) + ->setReturnType('static') + ->setPublic() + ->addComment('@param \Doctrine\Common\Collections\CollectiongetProxyClassname() . '> $' . $this->getProxiedVarName()) + ->addComment('@return $this') + ; + $proxySetter->addParameter($this->getProxiedVarName()) + ->setType('\Doctrine\Common\Collections\Collection'); + + $proxySetter->setBody(<<{$this->getProxiedVarName()} = \${$this->getProxiedVarName()}; +return \$this; +EOF + ); + + $setter = $classType->addMethod($this->field->getSetterName()) + ->setReturnType('static') + ->setPublic() + ->addComment('@return $this') + ; + $setter->addParameter($this->field->getVarName()) + ->setType('\Doctrine\Common\Collections\Collection|array|null'); + + $ucFieldVarName = ucwords($this->field->getVarName()); + + $setter->setBody(<<{$this->getProxiedGetterName()}() as \$item) { + \$item->{$this->getProxySelfSetterName()}(null); +} +\$this->{$this->getProxiedVarName()}->clear(); +if (null !== \${$this->field->getVarName()}) { + \$position = 0; + foreach (\${$this->field->getVarName()} as \$single{$ucFieldVarName}) { + \$proxyEntity = new {$this->getProxyClassname()}(); + \$proxyEntity->{$this->getProxySelfSetterName()}(\$this); + if (\$proxyEntity instanceof \RZ\Roadiz\Core\AbstractEntities\PositionedInterface) { + \$proxyEntity->setPosition(++\$position); } + \$proxyEntity->{$this->getProxyRelationSetterName()}(\$single{$ucFieldVarName}); + \$this->{$this->getProxiedVarName()}->add(\$proxyEntity); + \$this->objectManager->persist(\$proxyEntity); + } +} + +return \$this; +EOF + ); return $this; - }' . PHP_EOL; } /** @@ -234,16 +233,15 @@ protected function getProxyClassname(): string */ public function getCloneStatements(): string { - return ' - - $' . $this->getProxiedVarName() . 'Clone = new \Doctrine\Common\Collections\ArrayCollection(); - foreach ($this->' . $this->getProxiedVarName() . ' as $item) { - $itemClone = clone $item; - $itemClone->setNodeSource($this); - $' . $this->getProxiedVarName() . 'Clone->add($itemClone); - $this->objectManager->persist($itemClone); - } - $this->' . $this->getProxiedVarName() . ' = $' . $this->getProxiedVarName() . 'Clone; - '; + return <<getProxiedVarName()}Clone = new \Doctrine\Common\Collections\ArrayCollection(); +foreach (\$this->{$this->getProxiedVarName()} as \$item) { + \$itemClone = clone \$item; + \$itemClone->setNodeSource(\$this); + \${$this->getProxiedVarName()}Clone->add(\$itemClone); + \$this->objectManager->persist(\$itemClone); +} +\$this->{$this->getProxiedVarName()} = \${$this->getProxiedVarName()}Clone; +PHP; } } diff --git a/lib/EntityGenerator/src/Field/YamlFieldGenerator.php b/lib/EntityGenerator/src/Field/YamlFieldGenerator.php index c8c381d6..3d466ca1 100644 --- a/lib/EntityGenerator/src/Field/YamlFieldGenerator.php +++ b/lib/EntityGenerator/src/Field/YamlFieldGenerator.php @@ -4,32 +4,34 @@ namespace RZ\Roadiz\EntityGenerator\Field; -use RZ\Roadiz\EntityGenerator\Attribute\AttributeGenerator; -use RZ\Roadiz\EntityGenerator\Attribute\AttributeListGenerator; +use Nette\PhpGenerator\ClassType; +use Nette\PhpGenerator\Literal; +use Nette\PhpGenerator\Method; +use Nette\PhpGenerator\Property; -class YamlFieldGenerator extends NonVirtualFieldGenerator +final class YamlFieldGenerator extends NonVirtualFieldGenerator { - protected function getSerializationAttributes(): array + protected function addSerializationAttributes(Property|Method $property): self { - $annotations = parent::getSerializationAttributes(); + parent::addSerializationAttributes($property); if (!$this->excludeFromSerialization()) { - $annotations[] = new AttributeGenerator('Serializer\VirtualProperty'); - $annotations[] = new AttributeGenerator('Serializer\SerializedName', [ - AttributeGenerator::wrapString($this->field->getVarName()) + $property->addAttribute('JMS\Serializer\Annotation\VirtualProperty'); + $property->addAttribute('JMS\Serializer\Annotation\SerializedName', [ + $this->field->getVarName() ]); - $annotations[] = new AttributeGenerator('SymfonySerializer\SerializedName', [ - 'serializedName' => AttributeGenerator::wrapString($this->field->getVarName()) + $property->addAttribute('Symfony\Component\Serializer\Attribute\SerializedName', [ + 'serializedName' => $this->field->getVarName() ]); - $annotations[] = new AttributeGenerator('SymfonySerializer\Groups', [ + $property->addAttribute('Symfony\Component\Serializer\Attribute\Groups', [ $this->getSerializationGroups() ]); if ($this->getSerializationMaxDepth() > 0) { - $annotations[] = new AttributeGenerator('SymfonySerializer\MaxDepth', [ + $property->addAttribute('Symfony\Component\Serializer\Attribute\MaxDepth', [ $this->getSerializationMaxDepth() ]); } } - return $annotations; + return $this; } protected function getDefaultSerializationGroups(): array @@ -44,23 +46,28 @@ protected function isExcludingFieldFromJmsSerialization(): bool return false; } - /** - * @return string - */ - public function getFieldAlternativeGetter(): string + protected function hasFieldAlternativeGetter(): bool { - $assignation = '$this->' . $this->field->getVarName(); - return ' - /** - * @return object|array|null - */ -' . (new AttributeListGenerator($this->getSerializationAttributes()))->generate(4) . ' - public function ' . $this->field->getGetterName() . 'AsObject() + return true; + } + + public function addFieldAlternativeGetter(ClassType $classType): self { - if (null !== ' . $assignation . ') { - return \Symfony\Component\Yaml\Yaml::parse(' . $assignation . '); - } - return null; - }' . PHP_EOL; + $assignation = '$this->' . $this->field->getVarName(); + + $method = $classType->addMethod($this->field->getGetterName() . 'AsObject') + ->setReturnType('object|array|null') + ->setVisibility('public') + ; + $this->addSerializationAttributes($method); + $method->setBody(<<configureOptions($resolver); - $this->nodeType = $nodeType; $this->options = $resolver->resolve($options); } public function getClassContent(): string { - return $this->getClassHeader() . PHP_EOL . - $this->getClassBody(); + $file = new PhpFile(); + $file->setStrictTypes(); + $file->addComment('THIS IS A GENERATED FILE, DO NOT EDIT IT.'); + $file->addComment('IT WILL BE RECREATED AT EACH NODE-TYPE UPDATE.'); + + + $fqcn = $this->options['entity_namespace'] . '\\' . $this->nodeType->getSourceEntityClassName(); + $namespace = $file + ->addNamespace(trim($this->options['namespace'], '\\')) + ->addUse('\Doctrine\Persistence\ManagerRegistry') + ->addUse('\RZ\Roadiz\CoreBundle\Preview\PreviewResolverInterface') + ->addUse('\Symfony\Contracts\EventDispatcher\EventDispatcherInterface') + ->addUse('\Symfony\Bundle\SecurityBundle\Security') + ->addUse('\RZ\Roadiz\CoreBundle\SearchEngine\NodeSourceSearchHandlerInterface') + ->addUse($this->options['parent_class']) + ->addUse($fqcn) + ; + + $class = $namespace + ->addClass($this->options['class_name']) + ->setFinal() + ->setExtends($this->options['parent_class']) + ; + + $simplifiedFqcn = $namespace->simplifyName($fqcn); + $class + ->addComment('@extends ' . $namespace->simplifyName($this->options['parent_class']) . '<' . $simplifiedFqcn . '>') + ->addComment('@method ' . $simplifiedFqcn . '|null find($id, $lockMode = null, $lockVersion = null)') + ->addComment('@method ' . $simplifiedFqcn . '|null findOneBy(array $criteria, array $orderBy = null)') + ->addComment('@method ' . $simplifiedFqcn . '[] findAll()') + ->addComment('@method ' . $simplifiedFqcn . '[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)') + ; + + $constructor = $class->addMethod('__construct') + ->setBody( + 'parent::__construct($registry, $previewResolver, $dispatcher, $security, $nodeSourceSearchHandler, ' . $simplifiedFqcn . '::class);' + ); + + $constructor->addParameter('registry') + ->setType('\Doctrine\Persistence\ManagerRegistry'); + $constructor->addParameter('previewResolver') + ->setType('\RZ\Roadiz\CoreBundle\Preview\PreviewResolverInterface'); + $constructor->addParameter('dispatcher') + ->setType('\Symfony\Contracts\EventDispatcher\EventDispatcherInterface'); + $constructor->addParameter('security') + ->setType('\Symfony\Bundle\SecurityBundle\Security'); + $constructor->addParameter('nodeSourceSearchHandler') + ->setType('?\RZ\Roadiz\CoreBundle\SearchEngine\NodeSourceSearchHandlerInterface'); + + return (new PsrPrinter())->printFile($file); } public function configureOptions(OptionsResolver $resolver): void @@ -51,66 +99,4 @@ public function configureOptions(OptionsResolver $resolver): void $resolver->setNormalizer('entity_namespace', $normalizeClassName); $resolver->setNormalizer('namespace', $normalizeClassName); } - - /** - * @return string - */ - protected function getClassBody(): string - { - return 'class ' . $this->options['class_name'] . ' extends ' . $this->options['parent_class'] . ' -{' . $this->getClassConstructor() . '}' . PHP_EOL; - } - - /** - * @return string - */ - protected function getClassHeader(): string - { - $fqcn = $this->options['entity_namespace'] . '\\' . $this->nodeType->getSourceEntityClassName(); - /* - * BE CAREFUL, USE statements are required for field generators which - * are using ::class syntax! - */ - return 'options['namespace'], '\\') . '; - -use Doctrine\Persistence\ManagerRegistry; -use RZ\Roadiz\CoreBundle\Preview\PreviewResolverInterface; -use RZ\Roadiz\CoreBundle\SearchEngine\NodeSourceSearchHandlerInterface; -use Symfony\Bundle\SecurityBundle\Security; -use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; - -/** - * @extends ' . $this->options['parent_class'] . '<' . $fqcn . '> - * - * @method ' . $fqcn . '|null find($id, $lockMode = null, $lockVersion = null) - * @method ' . $fqcn . '|null findOneBy(array $criteria, array $orderBy = null) - * @method ' . $fqcn . '[] findAll() - * @method ' . $fqcn . '[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) - */'; - } - - /** - * @return string - */ - protected function getClassConstructor(): string - { - return ' - public function __construct( - ManagerRegistry $registry, - PreviewResolverInterface $previewResolver, - EventDispatcherInterface $dispatcher, - Security $security, - ?NodeSourceSearchHandlerInterface $nodeSourceSearchHandler - ) { - parent::__construct($registry, $previewResolver, $dispatcher, $security, $nodeSourceSearchHandler, ' . $this->options['entity_namespace'] . '\\' . $this->nodeType->getSourceEntityClassName() . '::class); - }' . PHP_EOL; - } } diff --git a/lib/EntityGenerator/tests/EntityGeneratorFactoryTest.php b/lib/EntityGenerator/tests/EntityGeneratorFactoryTest.php index 82185bce..dff56b7b 100644 --- a/lib/EntityGenerator/tests/EntityGeneratorFactoryTest.php +++ b/lib/EntityGenerator/tests/EntityGeneratorFactoryTest.php @@ -62,7 +62,7 @@ public function testCreateWithCustomRepository(): void * Uncomment for generating a mock file from tests */ // file_put_contents( -// dirname(__DIR__) . '/../test/mocks/GeneratedNodesSourcesWithRepository/NSMock.php', +// dirname(__DIR__) . '/tests/Mocks/GeneratedNodesSourcesWithRepository/NSMock.php', // $generator->createWithCustomRepository($this->getMockNodeType())->getClassContent() // ); @@ -92,7 +92,7 @@ public function testCreateCustomRepository(): void * Uncomment for generating a mock file from tests */ // file_put_contents( -// dirname(__DIR__) . '/../test/mocks/GeneratedNodesSourcesWithRepository/NSMockRepository.php', +// dirname(__DIR__) . '/tests/Mocks/GeneratedNodesSourcesWithRepository/Repository/NSMockRepository.php', // $generator->createCustomRepository($this->getMockNodeType())->getClassContent() // ); diff --git a/lib/EntityGenerator/tests/EntityGeneratorTest.php b/lib/EntityGenerator/tests/EntityGeneratorTest.php index df911556..5741180c 100644 --- a/lib/EntityGenerator/tests/EntityGeneratorTest.php +++ b/lib/EntityGenerator/tests/EntityGeneratorTest.php @@ -43,8 +43,8 @@ public function testGetClassContent(): void * Uncomment for generating a mock file from tests */ // file_put_contents( -// dirname(__DIR__) . '/../test/mocks/GeneratedNodesSources/NSMock.php', -// $dumpInstance->getClassContent() +// dirname(__DIR__) . '/tests/Mocks/GeneratedNodesSources/NSMock.php', +// $generator->getClassContent() // ); $this->assertEquals( diff --git a/lib/EntityGenerator/tests/Mocks/GeneratedNodesSources/NSMock.php b/lib/EntityGenerator/tests/Mocks/GeneratedNodesSources/NSMock.php index 5b5e167a..5d862349 100644 --- a/lib/EntityGenerator/tests/Mocks/GeneratedNodesSources/NSMock.php +++ b/lib/EntityGenerator/tests/Mocks/GeneratedNodesSources/NSMock.php @@ -1,55 +1,431 @@ false])] + #[JMS\Groups(['nodes_sources', 'nodes_sources_default'])] + #[JMS\MaxDepth(1)] + #[JMS\Type('bool')] + private bool $boolIndexed = false; + + /** + * Foo markdown field. + * Maecenas sed diam eget risus varius blandit sit amet non magna. + * Default values: + * allow_h2: false + * allow_h3: false + * allow_h4: false + * allow_h5: false + * allow_h6: false + * allow_bold: true + * allow_italic: true + * allow_blockquote: false + * allow_image: false + * allow_list: false + * allow_nbsp: true + * allow_nb_hyphen: true + * allow_return: true + * allow_link: false + * allow_hr: false + * allow_preview: true + */ + #[Serializer\SerializedName(serializedName: 'fooMarkdown')] + #[Serializer\Groups(['nodes_sources', 'nodes_sources_default'])] + #[ApiProperty(description: 'Foo markdown field: Maecenas sed diam eget risus varius blandit sit amet non magna')] + #[Serializer\MaxDepth(1)] + #[Gedmo\Versioned] + #[ORM\Column(name: 'foo_markdown', type: 'text', nullable: true)] + #[JMS\Groups(['nodes_sources', 'nodes_sources_default'])] + #[JMS\MaxDepth(1)] + #[JMS\Type('string')] + private ?string $fooMarkdown = null; + + /** + * Foo excluded markdown field. + * Maecenas sed diam eget risus varius blandit sit amet non magna. + * Default values: + * allow_h2: false + * allow_h3: false + * allow_h4: false + * allow_h5: false + * allow_h6: false + * allow_bold: true + * allow_italic: true + * allow_blockquote: false + * allow_image: false + * allow_list: false + * allow_nbsp: true + * allow_nb_hyphen: true + * allow_return: true + * allow_link: false + * allow_hr: false + * allow_preview: true + */ + #[Gedmo\Versioned] + #[ORM\Column(name: 'foo_markdown_excluded', type: 'text', nullable: true)] + #[JMS\Exclude] + #[Serializer\Ignore] + private ?string $fooMarkdownExcluded = null; + + /** + * Foo expression excluded decimal. + * Maecenas sed diam eget risus varius blandit sit amet non magna. + */ + #[Serializer\SerializedName(serializedName: 'fooDecimalExcluded')] + #[Serializer\Groups(['nodes_sources', 'nodes_sources_default'])] + #[ApiProperty(description: 'Foo expression excluded decimal: Maecenas sed diam eget risus varius blandit sit amet non magna')] + #[Serializer\MaxDepth(2)] + #[ApiFilter(\ApiPlatform\Doctrine\Orm\Filter\OrderFilter::class)] + #[ApiFilter(\ApiPlatform\Doctrine\Orm\Filter\NumericFilter::class)] + #[ApiFilter(\ApiPlatform\Doctrine\Orm\Filter\RangeFilter::class)] + #[Gedmo\Versioned] + #[ORM\Column(name: 'foo_decimal_excluded', type: 'decimal', nullable: true, precision: 18, scale: 3)] + #[JMS\Groups(['nodes_sources', 'nodes_sources_default'])] + #[JMS\MaxDepth(2)] + #[JMS\Exclude(if: 'object.foo == \'test\'')] + #[JMS\Type('double')] + private int|float|null $fooDecimalExcluded = null; + + /** + * Référence à l'événement. + * Maecenas sed diam eget risus varius blandit sit amet non magna. + * Default values: + * # Entity class name + * classname: \App\Entity\Base\Event + * # Displayable is the method used to display entity name + * displayable: getName + * # Same as Displayable but for a secondary information + * alt_displayable: getSortingFirstDateTime + * # Same as Displayable but for a secondary information + * thumbnail: getMainDocument + * # Searchable entity fields + * searchable: + * - name + * - slug + * # This order will only be used for explorer + * orderBy: + * - field: sortingLastDateTime + * direction: DESC + */ + #[Serializer\SerializedName(serializedName: 'singleEventReference')] + #[Serializer\Groups(['nodes_sources', 'nodes_sources_default'])] + #[ApiProperty(description: 'Référence à l\'événement: Maecenas sed diam eget risus varius blandit sit amet non magna')] + #[Serializer\MaxDepth(2)] + #[ORM\ManyToOne(targetEntity: \App\Entity\Base\Event::class)] + #[ORM\JoinColumn(name: 'single_event_reference_id', referencedColumnName: 'id', onDelete: 'SET NULL')] + #[ApiFilter(\ApiPlatform\Doctrine\Orm\Filter\SearchFilter::class, strategy: 'exact')] + #[JMS\Groups(['nodes_sources', 'nodes_sources_default'])] + #[JMS\MaxDepth(2)] + private ?\App\Entity\Base\Event $singleEventReference = null; + + /** + * Remontée d'événements manuelle. + * Maecenas sed diam eget risus varius blandit sit amet non magna. + * Default values: + * # Entity class name + * classname: \App\Entity\Base\Event + * # Displayable is the method used to display entity name + * displayable: getName + * # Same as Displayable but for a secondary information + * alt_displayable: getSortingFirstDateTime + * # Same as Displayable but for a secondary information + * thumbnail: getMainDocument + * # Searchable entity fields + * searchable: + * - name + * - slug + * # This order will only be used for explorer + * orderBy: + * - field: sortingLastDateTime + * direction: DESC + * @var \Doctrine\Common\Collections\Collection + */ + #[Serializer\SerializedName(serializedName: 'eventReferences')] + #[Serializer\Groups(['nodes_sources', 'nodes_sources_default'])] + #[ApiProperty(description: 'Remontée d\'événements manuelle: Maecenas sed diam eget risus varius blandit sit amet non magna')] + #[Serializer\MaxDepth(2)] + #[ORM\ManyToMany(targetEntity: \App\Entity\Base\Event::class)] + #[ORM\JoinTable(name: 'node_type_event_references')] + #[ORM\JoinColumn(name: 'node_type_id', referencedColumnName: 'id', onDelete: 'CASCADE')] + #[ORM\InverseJoinColumn(name: 'event_references_id', referencedColumnName: 'id', onDelete: 'CASCADE')] + #[ORM\OrderBy(['sortingLastDateTime' => 'DESC'])] + #[ApiFilter(\ApiPlatform\Doctrine\Orm\Filter\SearchFilter::class, strategy: 'exact')] + #[JMS\Groups(['nodes_sources', 'nodes_sources_default'])] + #[JMS\MaxDepth(2)] + private Collection $eventReferences; + + /** + * Buffer var to get referenced entities (documents, nodes, cforms, doctrine entities) + * Remontée d'événements manuelle. + * @var \Doctrine\Common\Collections\Collection + */ + #[JMS\Exclude] + #[Serializer\Ignore] + #[ORM\OneToMany( + targetEntity: \App\Entity\PositionedCity::class, + mappedBy: 'nodeSource', + orphanRemoval: true, + cascade: ['persist', 'remove'], + )] + #[ORM\OrderBy(['position' => 'ASC'])] + private Collection $eventReferencesProxiedProxy; + + /** + * Remontée d'événements manuelle exclue. + * Maecenas sed diam eget risus varius blandit sit amet non magna. + * Default values: + * # Entity class name + * classname: \App\Entity\Base\Event + * # Displayable is the method used to display entity name + * displayable: getName + * # Same as Displayable but for a secondary information + * alt_displayable: getSortingFirstDateTime + * # Same as Displayable but for a secondary information + * thumbnail: getMainDocument + * # Searchable entity fields + * searchable: + * - name + * - slug + * # This order will only be used for explorer + * orderBy: + * - field: sortingLastDateTime + * direction: DESC + * @var \Doctrine\Common\Collections\Collection + */ + #[ORM\ManyToMany(targetEntity: \App\Entity\Base\Event::class)] + #[ORM\JoinTable(name: 'node_type_event_references_excluded')] + #[ORM\JoinColumn(name: 'node_type_id', referencedColumnName: 'id', onDelete: 'CASCADE')] + #[ORM\InverseJoinColumn(name: 'event_references_excluded_id', referencedColumnName: 'id', onDelete: 'CASCADE')] + #[ORM\OrderBy(['sortingLastDateTime' => 'DESC'])] + #[ApiFilter(\ApiPlatform\Doctrine\Orm\Filter\SearchFilter::class, strategy: 'exact')] + #[JMS\Exclude] + #[Serializer\Ignore] + private Collection $eventReferencesExcluded; + + /** + * Bar documents field. + * Maecenas sed diam eget risus varius blandit sit amet non magna. + * (Virtual field, this var is a buffer) + */ + #[JMS\Exclude] + #[Serializer\SerializedName(serializedName: 'bar')] + #[Serializer\Groups(['nodes_sources', 'nodes_sources_default', 'nodes_sources_documents'])] + #[ApiProperty(description: 'Bar documents field: Maecenas sed diam eget risus varius blandit sit amet non magna')] + #[Serializer\MaxDepth(1)] + private ?array $bar = null; + + /** + * Custom forms field. + * (Virtual field, this var is a buffer) + */ + #[JMS\Exclude] + #[Serializer\SerializedName(serializedName: 'theForms')] + #[Serializer\Groups(['nodes_sources', 'nodes_sources_default', 'nodes_sources_custom_forms'])] + #[ApiProperty(description: 'Custom forms field')] + #[Serializer\MaxDepth(2)] + private ?array $theForms = null; + + /** + * fooBarSources NodesSources direct field buffer. + * @var \mock\Entity\NodesSources[]|null + * ForBar nodes field. + * Maecenas sed diam eget risus varius blandit sit amet non magna. + */ + #[JMS\Exclude] + #[Serializer\SerializedName(serializedName: 'fooBar')] + #[Serializer\Groups(['nodes_sources', 'nodes_sources_default', 'nodes_sources_nodes'])] + #[ApiProperty(description: 'ForBar nodes field: Maecenas sed diam eget risus varius blandit sit amet non magna')] + #[Serializer\MaxDepth(2)] + private ?array $fooBarSources = null; + + /** + * fooBarHiddenSources NodesSources direct field buffer. + * @var \mock\Entity\NodesSources[]|null + * ForBar hidden nodes field. + * Maecenas sed diam eget risus varius blandit sit amet non magna. + */ + #[JMS\Exclude] + private ?array $fooBarHiddenSources = null; + + /** + * fooBarTypedSources NodesSources direct field buffer. + * @var \tests\mocks\GeneratedNodesSources\NSMockTwo[]|null + * ForBar nodes typed field. + * Default values: + * MockTwo + */ + #[JMS\Exclude] + #[Serializer\SerializedName(serializedName: 'fooBarTyped')] + #[Serializer\Groups(['nodes_sources', 'nodes_sources_default', 'nodes_sources_nodes'])] + #[ApiProperty(description: 'ForBar nodes typed field')] + #[Serializer\MaxDepth(2)] + private ?array $fooBarTypedSources = null; + + /** + * ForBar layout enum. + * Default values: + * light, dark, transparent + */ + #[Serializer\SerializedName(serializedName: 'layout')] + #[Serializer\Groups(['nodes_sources', 'nodes_sources_default'])] + #[ApiProperty( + description: 'ForBar layout enum', + schema: ['type' => 'string', 'enum' => ['light', 'dark', 'transparent'], 'example' => 'light'], + )] + #[Serializer\MaxDepth(2)] + #[ApiFilter(\ApiPlatform\Doctrine\Orm\Filter\SearchFilter::class, strategy: 'exact')] + #[ApiFilter(\RZ\Roadiz\CoreBundle\Api\Filter\NotFilter::class)] + #[Gedmo\Versioned] + #[ORM\Column(name: 'layout', type: 'string', nullable: true, length: 11)] + #[JMS\Groups(['nodes_sources', 'nodes_sources_default'])] + #[JMS\MaxDepth(2)] + #[JMS\Type('string')] + private ?string $layout = null; + + /** + * For many_to_one field. + * Default values: + * classname: \MyCustomEntity + * displayable: getName + */ + #[Serializer\SerializedName(serializedName: 'fooManyToOne')] + #[Serializer\Groups(['nodes_sources', 'nodes_sources_default'])] + #[ApiProperty(description: 'For many_to_one field')] + #[Serializer\MaxDepth(2)] + #[ORM\ManyToOne(targetEntity: \MyCustomEntity::class)] + #[ORM\JoinColumn(name: 'foo_many_to_one_id', referencedColumnName: 'id', onDelete: 'SET NULL')] + #[ApiFilter(\ApiPlatform\Doctrine\Orm\Filter\SearchFilter::class, strategy: 'exact')] + #[JMS\Groups(['nodes_sources', 'nodes_sources_default'])] + #[JMS\MaxDepth(2)] + private ?\MyCustomEntity $fooManyToOne = null; + + /** + * For many_to_many field. + * Default values: + * classname: \MyCustomEntity + * displayable: getName + * orderBy: + * - field: name + * direction: asc + * @var \Doctrine\Common\Collections\Collection + */ + #[Serializer\SerializedName(serializedName: 'fooManyToMany')] + #[Serializer\Groups(['nodes_sources', 'nodes_sources_default'])] + #[ApiProperty(description: 'For many_to_many field')] + #[Serializer\MaxDepth(2)] + #[ORM\ManyToMany(targetEntity: \MyCustomEntity::class)] + #[ORM\JoinTable(name: 'node_type_foo_many_to_many')] + #[ORM\JoinColumn(name: 'node_type_id', referencedColumnName: 'id', onDelete: 'CASCADE')] + #[ORM\InverseJoinColumn(name: 'foo_many_to_many_id', referencedColumnName: 'id', onDelete: 'CASCADE')] + #[ORM\OrderBy(['name' => 'asc'])] + #[ApiFilter(\ApiPlatform\Doctrine\Orm\Filter\SearchFilter::class, strategy: 'exact')] + #[JMS\Groups(['nodes_sources', 'nodes_sources_default'])] + #[JMS\MaxDepth(2)] + private Collection $fooManyToMany; + + /** + * Buffer var to get referenced entities (documents, nodes, cforms, doctrine entities) + * For many_to_many proxied field. + * @var \Doctrine\Common\Collections\Collection + */ + #[JMS\Exclude] + #[Serializer\Ignore] + #[ORM\OneToMany( + targetEntity: \Themes\MyTheme\Entities\PositionedCity::class, + mappedBy: 'nodeSource', + orphanRemoval: true, + cascade: ['persist', 'remove'], + )] + #[ORM\OrderBy(['position' => 'ASC'])] + private Collection $fooManyToManyProxiedProxy; /** * @return \DateTime|null @@ -60,40 +436,14 @@ public function getFooDatetime(): ?\DateTime } /** - * @param \DateTime|null $fooDatetime - * * @return $this */ public function setFooDatetime(?\DateTime $fooDatetime): static { $this->fooDatetime = $fooDatetime; - return $this; } - - /** - * Foo field. - * Maecenas sed diam eget risus varius blandit sit amet non magna. - */ - #[ - SymfonySerializer\SerializedName(serializedName: "foo"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_default"]), - \ApiPlatform\Metadata\ApiProperty(description: "Foo field: Maecenas sed diam eget risus varius blandit sit amet non magna"), - SymfonySerializer\MaxDepth(1), - Gedmo\Versioned, - ORM\Column( - name: "foo", - type: "string", - nullable: true, - length: 250 - ), - Serializer\Groups(["nodes_sources", "nodes_sources_default"]), - Serializer\MaxDepth(1), - Serializer\Type("string") - ] - private ?string $foo = null; - /** * @return string|null */ @@ -103,44 +453,16 @@ public function getFoo(): ?string } /** - * @param string|null $foo - * * @return $this */ public function setFoo(?string $foo): static { $this->foo = null !== $foo ? - (string) $foo : - null; - + (string) $foo : + null; return $this; } - - /** - * Foo indexed field. - * Maecenas sed diam eget risus varius blandit sit amet non magna. - */ - #[ - SymfonySerializer\SerializedName(serializedName: "fooIndexed"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_default"]), - \ApiPlatform\Metadata\ApiProperty(description: "Foo indexed field: Maecenas sed diam eget risus varius blandit sit amet non magna"), - SymfonySerializer\MaxDepth(1), - ApiFilter(OrmFilter\SearchFilter::class, strategy: "partial"), - ApiFilter(\RZ\Roadiz\CoreBundle\Api\Filter\NotFilter::class), - Gedmo\Versioned, - ORM\Column( - name: "fooIndexed", - type: "string", - nullable: true, - length: 250 - ), - Serializer\Groups(["nodes_sources", "nodes_sources_default"]), - Serializer\MaxDepth(1), - Serializer\Type("string") - ] - private ?string $fooIndexed = null; - /** * @return string|null */ @@ -150,44 +472,16 @@ public function getFooIndexed(): ?string } /** - * @param string|null $fooIndexed - * * @return $this */ public function setFooIndexed(?string $fooIndexed): static { $this->fooIndexed = null !== $fooIndexed ? - (string) $fooIndexed : - null; - + (string) $fooIndexed : + null; return $this; } - - /** - * Bool indexed field. - * Maecenas sed diam eget risus varius blandit sit amet non magna. - */ - #[ - SymfonySerializer\SerializedName(serializedName: "boolIndexed"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_default"]), - \ApiPlatform\Metadata\ApiProperty(description: "Bool indexed field: Maecenas sed diam eget risus varius blandit sit amet non magna"), - SymfonySerializer\MaxDepth(1), - ApiFilter(OrmFilter\OrderFilter::class), - ApiFilter(OrmFilter\BooleanFilter::class), - Gedmo\Versioned, - ORM\Column( - name: "boolIndexed", - type: "boolean", - nullable: false, - options: ["default" => false] - ), - Serializer\Groups(["nodes_sources", "nodes_sources_default"]), - Serializer\MaxDepth(1), - Serializer\Type("bool") - ] - private bool $boolIndexed = false; - /** * @return bool */ @@ -197,51 +491,14 @@ public function getBoolIndexed(): bool } /** - * @param bool $boolIndexed - * * @return $this */ public function setBoolIndexed(bool $boolIndexed): static { $this->boolIndexed = $boolIndexed; - return $this; } - - /** - * Foo markdown field. - * Maecenas sed diam eget risus varius blandit sit amet non magna. - * Default values: allow_h2: false - * allow_h3: false - * allow_h4: false - * allow_h5: false - * allow_h6: false - * allow_bold: true - * allow_italic: true - * allow_blockquote: false - * allow_image: false - * allow_list: false - * allow_nbsp: true - * allow_nb_hyphen: true - * allow_return: true - * allow_link: false - * allow_hr: false - * allow_preview: true - */ - #[ - SymfonySerializer\SerializedName(serializedName: "fooMarkdown"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_default"]), - \ApiPlatform\Metadata\ApiProperty(description: "Foo markdown field: Maecenas sed diam eget risus varius blandit sit amet non magna"), - SymfonySerializer\MaxDepth(1), - Gedmo\Versioned, - ORM\Column(name: "foo_markdown", type: "text", nullable: true), - Serializer\Groups(["nodes_sources", "nodes_sources_default"]), - Serializer\MaxDepth(1), - Serializer\Type("string") - ] - private ?string $fooMarkdown = null; - /** * @return string|null */ @@ -251,48 +508,16 @@ public function getFooMarkdown(): ?string } /** - * @param string|null $fooMarkdown - * * @return $this */ public function setFooMarkdown(?string $fooMarkdown): static { $this->fooMarkdown = null !== $fooMarkdown ? - (string) $fooMarkdown : - null; - + (string) $fooMarkdown : + null; return $this; } - - /** - * Foo excluded markdown field. - * Maecenas sed diam eget risus varius blandit sit amet non magna. - * Default values: allow_h2: false - * allow_h3: false - * allow_h4: false - * allow_h5: false - * allow_h6: false - * allow_bold: true - * allow_italic: true - * allow_blockquote: false - * allow_image: false - * allow_list: false - * allow_nbsp: true - * allow_nb_hyphen: true - * allow_return: true - * allow_link: false - * allow_hr: false - * allow_preview: true - */ - #[ - Gedmo\Versioned, - ORM\Column(name: "foo_markdown_excluded", type: "text", nullable: true), - Serializer\Exclude, - SymfonySerializer\Ignore - ] - private ?string $fooMarkdownExcluded = null; - /** * @return string|null */ @@ -302,47 +527,16 @@ public function getFooMarkdownExcluded(): ?string } /** - * @param string|null $fooMarkdownExcluded - * * @return $this */ public function setFooMarkdownExcluded(?string $fooMarkdownExcluded): static { $this->fooMarkdownExcluded = null !== $fooMarkdownExcluded ? - (string) $fooMarkdownExcluded : - null; - + (string) $fooMarkdownExcluded : + null; return $this; } - - /** - * Foo expression excluded decimal. - * Maecenas sed diam eget risus varius blandit sit amet non magna. - */ - #[ - SymfonySerializer\SerializedName(serializedName: "fooDecimalExcluded"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_default"]), - \ApiPlatform\Metadata\ApiProperty(description: "Foo expression excluded decimal: Maecenas sed diam eget risus varius blandit sit amet non magna"), - SymfonySerializer\MaxDepth(2), - ApiFilter(OrmFilter\OrderFilter::class), - ApiFilter(OrmFilter\NumericFilter::class), - ApiFilter(OrmFilter\RangeFilter::class), - Gedmo\Versioned, - ORM\Column( - name: "foo_decimal_excluded", - type: "decimal", - nullable: true, - precision: 18, - scale: 3 - ), - Serializer\Groups(["nodes_sources", "nodes_sources_default"]), - Serializer\MaxDepth(2), - Serializer\Exclude(if: "object.foo == 'test'"), - Serializer\Type("double") - ] - private int|float|null $fooDecimalExcluded = null; - /** * @return int|float|null */ @@ -352,111 +546,30 @@ public function getFooDecimalExcluded(): int|float|null } /** - * @param int|float|null $fooDecimalExcluded - * * @return $this */ public function setFooDecimalExcluded(int|float|null $fooDecimalExcluded): static { $this->fooDecimalExcluded = $fooDecimalExcluded; - return $this; } - - /** - * Référence à l'événement. - * Maecenas sed diam eget risus varius blandit sit amet non magna. - * Default values: # Entity class name - * classname: \App\Entity\Base\Event - * # Displayable is the method used to display entity name - * displayable: getName - * # Same as Displayable but for a secondary information - * alt_displayable: getSortingFirstDateTime - * # Same as Displayable but for a secondary information - * thumbnail: getMainDocument - * # Searchable entity fields - * searchable: - * - name - * - slug - * # This order will only be used for explorer - * orderBy: - * - field: sortingLastDateTime - * direction: DESC - * @var \App\Entity\Base\Event|null - */ - #[ - SymfonySerializer\SerializedName(serializedName: "singleEventReference"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_default"]), - \ApiPlatform\Metadata\ApiProperty(description: "Référence à l'événement: Maecenas sed diam eget risus varius blandit sit amet non magna"), - SymfonySerializer\MaxDepth(2), - ORM\ManyToOne(targetEntity: \App\Entity\Base\Event::class), - ORM\JoinColumn(name: "single_event_reference_id", referencedColumnName: "id", onDelete: "SET NULL"), - ApiFilter(OrmFilter\SearchFilter::class, strategy: "exact"), - Serializer\Groups(["nodes_sources", "nodes_sources_default"]), - Serializer\MaxDepth(2) - ] - private ?\App\Entity\Base\Event $singleEventReference = null; - - /** - * @return \App\Entity\Base\Event|null - */ public function getSingleEventReference(): ?\App\Entity\Base\Event { return $this->singleEventReference; } /** - * @param \App\Entity\Base\Event|null $singleEventReference * @return $this */ - public function setSingleEventReference(?\App\Entity\Base\Event $singleEventReference = null): static + public function setSingleEventReference(?\App\Entity\Base\Event $singleEventReference): static { $this->singleEventReference = $singleEventReference; - return $this; } - /** - * Remontée d'événements manuelle. - * Maecenas sed diam eget risus varius blandit sit amet non magna. - * Default values: # Entity class name - * classname: \App\Entity\Base\Event - * # Displayable is the method used to display entity name - * displayable: getName - * # Same as Displayable but for a secondary information - * alt_displayable: getSortingFirstDateTime - * # Same as Displayable but for a secondary information - * thumbnail: getMainDocument - * # Searchable entity fields - * searchable: - * - name - * - slug - * # This order will only be used for explorer - * orderBy: - * - field: sortingLastDateTime - * direction: DESC - * @var Collection - */ - #[ - SymfonySerializer\SerializedName(serializedName: "eventReferences"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_default"]), - \ApiPlatform\Metadata\ApiProperty(description: "Remontée d'événements manuelle: Maecenas sed diam eget risus varius blandit sit amet non magna"), - SymfonySerializer\MaxDepth(2), - ORM\ManyToMany(targetEntity: \App\Entity\Base\Event::class), - ORM\JoinTable(name: "node_type_event_references"), - ORM\JoinColumn(name: "node_type_id", referencedColumnName: "id", onDelete: "CASCADE"), - ORM\InverseJoinColumn(name: "event_references_id", referencedColumnName: "id", onDelete: "CASCADE"), - ORM\OrderBy(["sortingLastDateTime" => "DESC"]), - ApiFilter(OrmFilter\SearchFilter::class, strategy: "exact"), - Serializer\Groups(["nodes_sources", "nodes_sources_default"]), - Serializer\MaxDepth(2) - ] - private Collection $eventReferences; - - /** - * @return Collection + * @return \Doctrine\Common\Collections\Collection */ public function getEventReferences(): Collection { @@ -464,7 +577,7 @@ public function getEventReferences(): Collection } /** - * @param Collection|\App\Entity\Base\Event[] $eventReferences + * @param \Doctrine\Common\Collections\Collection|array<\App\Entity\Base\Event> $eventReferences * @return $this */ public function setEventReferences(Collection|array $eventReferences): static @@ -474,72 +587,45 @@ public function setEventReferences(Collection|array $eventReferences): static } else { $this->eventReferences = new \Doctrine\Common\Collections\ArrayCollection($eventReferences); } - return $this; } - - /** - * Remontée d'événements manuelle - * - * @var Collection - */ - #[ - Serializer\Exclude, - SymfonySerializer\Ignore, - ORM\OneToMany( - targetEntity: \App\Entity\PositionedCity::class, - mappedBy: "nodeSource", - orphanRemoval: true, - cascade: ["persist", "remove"] - ), - ORM\OrderBy(["position" => "ASC"]) - ] - private Collection $eventReferencesProxiedProxy; - /** - * @return Collection + * @return \Doctrine\Common\Collections\Collection */ public function getEventReferencesProxiedProxy(): Collection { return $this->eventReferencesProxiedProxy; } - /** - * @return Collection - */ - #[ - Serializer\Groups(["nodes_sources", "nodes_sources_default"]), - Serializer\MaxDepth(2), - Serializer\VirtualProperty, - Serializer\SerializedName("eventReferencesProxied"), - SymfonySerializer\SerializedName(serializedName: "eventReferencesProxied"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_default"]), - SymfonySerializer\MaxDepth(2) - ] - public function getEventReferencesProxied(): Collection + #[JMS\Groups(['nodes_sources', 'nodes_sources_default'])] + #[JMS\MaxDepth(2)] + #[JMS\VirtualProperty] + #[JMS\SerializedName('eventReferencesProxied')] + #[Serializer\SerializedName(serializedName: 'eventReferencesProxied')] + #[Serializer\Groups(['nodes_sources', 'nodes_sources_default'])] + #[Serializer\MaxDepth(2)] + public function getEventReferencesProxied(): array { return $this->eventReferencesProxiedProxy->map(function (\App\Entity\PositionedCity $proxyEntity) { return $proxyEntity->getCity(); - }); + })->getValues(); } /** - * @param Collection $eventReferencesProxiedProxy - * @Serializer\VirtualProperty() + * @param \Doctrine\Common\Collections\Collection $eventReferencesProxiedProxy * @return $this */ public function setEventReferencesProxiedProxy(Collection $eventReferencesProxiedProxy): static { $this->eventReferencesProxiedProxy = $eventReferencesProxiedProxy; - return $this; } + /** - * @param Collection|array|null $eventReferencesProxied * @return $this */ - public function setEventReferencesProxied(Collection|array|null $eventReferencesProxied = null): static + public function setEventReferencesProxied(Collection|array|null $eventReferencesProxied): static { foreach ($this->getEventReferencesProxiedProxy() as $item) { $item->setNodeSource(null); @@ -562,42 +648,8 @@ public function setEventReferencesProxied(Collection|array|null $eventReferences return $this; } - - /** - * Remontée d'événements manuelle exclue. - * Maecenas sed diam eget risus varius blandit sit amet non magna. - * Default values: # Entity class name - * classname: \App\Entity\Base\Event - * # Displayable is the method used to display entity name - * displayable: getName - * # Same as Displayable but for a secondary information - * alt_displayable: getSortingFirstDateTime - * # Same as Displayable but for a secondary information - * thumbnail: getMainDocument - * # Searchable entity fields - * searchable: - * - name - * - slug - * # This order will only be used for explorer - * orderBy: - * - field: sortingLastDateTime - * direction: DESC - * @var Collection - */ - #[ - ORM\ManyToMany(targetEntity: \App\Entity\Base\Event::class), - ORM\JoinTable(name: "node_type_event_references_excluded"), - ORM\JoinColumn(name: "node_type_id", referencedColumnName: "id", onDelete: "CASCADE"), - ORM\InverseJoinColumn(name: "event_references_excluded_id", referencedColumnName: "id", onDelete: "CASCADE"), - ORM\OrderBy(["sortingLastDateTime" => "DESC"]), - ApiFilter(OrmFilter\SearchFilter::class, strategy: "exact"), - Serializer\Exclude, - SymfonySerializer\Ignore - ] - private Collection $eventReferencesExcluded; - /** - * @return Collection + * @return \Doctrine\Common\Collections\Collection */ public function getEventReferencesExcluded(): Collection { @@ -605,7 +657,7 @@ public function getEventReferencesExcluded(): Collection } /** - * @param Collection|\App\Entity\Base\Event[] $eventReferencesExcluded + * @param \Doctrine\Common\Collections\Collection|array<\App\Entity\Base\Event> $eventReferencesExcluded * @return $this */ public function setEventReferencesExcluded(Collection|array $eventReferencesExcluded): static @@ -615,36 +667,17 @@ public function setEventReferencesExcluded(Collection|array $eventReferencesExcl } else { $this->eventReferencesExcluded = new \Doctrine\Common\Collections\ArrayCollection($eventReferencesExcluded); } - return $this; } - - /** - * Bar documents field. - * Maecenas sed diam eget risus varius blandit sit amet non magna. - * - * (Virtual field, this var is a buffer) - */ - #[ - Serializer\Exclude, - SymfonySerializer\SerializedName(serializedName: "bar"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_default", "nodes_sources_documents"]), - \ApiPlatform\Metadata\ApiProperty(description: "Bar documents field: Maecenas sed diam eget risus varius blandit sit amet non magna"), - SymfonySerializer\MaxDepth(1) - ] - private ?array $bar = null; - /** - * @return \mock\Entity\Document[] Documents array + * @return \mock\Entity\Document[] */ - #[ - Serializer\Groups(["nodes_sources", "nodes_sources_default", "nodes_sources_documents"]), - Serializer\MaxDepth(1), - Serializer\VirtualProperty, - Serializer\SerializedName("bar"), - Serializer\Type("array") - ] + #[JMS\Groups(['nodes_sources', 'nodes_sources_default', 'nodes_sources_documents'])] + #[JMS\MaxDepth(1)] + #[JMS\VirtualProperty] + #[JMS\SerializedName('bar')] + #[JMS\Type('array')] public function getBar(): array { if (null === $this->bar) { @@ -663,51 +696,33 @@ public function getBar(): array } /** - * @param \mock\Entity\Document $document - * * @return $this */ public function addBar(\mock\Entity\Document $document): static { - if (null !== $this->objectManager) { - $nodeSourceDocument = new \mock\Entity\NodesSourcesDocument( - $this, - $document - ); - $nodeSourceDocument->setFieldName('bar'); - if (!$this->hasNodesSourcesDocuments($nodeSourceDocument)) { - $this->objectManager->persist($nodeSourceDocument); - $this->addDocumentsByFields($nodeSourceDocument); - $this->bar = null; - } + if (null === $this->objectManager) { + return $this; + } + $nodeSourceDocument = new \mock\Entity\NodesSourcesDocument( + $this, + $document + ); + $nodeSourceDocument->setFieldName('bar'); + if (!$this->hasNodesSourcesDocuments($nodeSourceDocument)) { + $this->objectManager->persist($nodeSourceDocument); + $this->addDocumentsByFields($nodeSourceDocument); + $this->bar = null; } return $this; } - - /** - * Custom forms field. - * - * (Virtual field, this var is a buffer) - */ - #[ - Serializer\Exclude, - SymfonySerializer\SerializedName(serializedName: "theForms"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_default", "nodes_sources_custom_forms"]), - \ApiPlatform\Metadata\ApiProperty(description: "Custom forms field"), - SymfonySerializer\MaxDepth(2) - ] - private ?array $theForms = null; - /** * @return \mock\Entity\CustomForm[] CustomForm array */ - #[ - Serializer\Groups(["nodes_sources", "nodes_sources_default", "nodes_sources_custom_forms"]), - Serializer\MaxDepth(2), - Serializer\VirtualProperty, - Serializer\SerializedName("theForms") - ] + #[JMS\Groups(['nodes_sources', 'nodes_sources_default', 'nodes_sources_custom_forms'])] + #[JMS\MaxDepth(2)] + #[JMS\VirtualProperty] + #[JMS\SerializedName('theForms')] public function getTheForms(): array { if (null === $this->theForms) { @@ -726,8 +741,6 @@ public function getTheForms(): array } /** - * @param \mock\Entity\CustomForm $customForm - * * @return $this */ public function addTheForms(\mock\Entity\CustomForm $customForm): static @@ -745,34 +758,14 @@ public function addTheForms(\mock\Entity\CustomForm $customForm): static return $this; } - - /** - * fooBarSources NodesSources direct field buffer. - * (Virtual field, this var is a buffer) - * - * ForBar nodes field. - * Maecenas sed diam eget risus varius blandit sit amet non magna. - * @var \mock\Entity\NodesSources[]|null - */ - #[ - Serializer\Exclude, - SymfonySerializer\SerializedName(serializedName: "fooBar"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_default", "nodes_sources_nodes"]), - \ApiPlatform\Metadata\ApiProperty(description: "ForBar nodes field: Maecenas sed diam eget risus varius blandit sit amet non magna"), - SymfonySerializer\MaxDepth(2) - ] - private ?array $fooBarSources = null; - /** - * @return \mock\Entity\NodesSources[] fooBar nodes-sources array + * @return \mock\Entity\NodesSources[] */ - #[ - Serializer\Groups(["nodes_sources", "nodes_sources_default", "nodes_sources_nodes"]), - Serializer\MaxDepth(2), - Serializer\VirtualProperty, - Serializer\SerializedName("fooBar"), - Serializer\Type("array") - ] + #[JMS\Groups(['nodes_sources', 'nodes_sources_default', 'nodes_sources_nodes'])] + #[JMS\MaxDepth(2)] + #[JMS\VirtualProperty] + #[JMS\SerializedName('fooBar')] + #[JMS\Type('array')] public function getFooBarSources(): array { if (null === $this->fooBarSources) { @@ -792,38 +785,22 @@ public function getFooBarSources(): array /** * @param \mock\Entity\NodesSources[]|null $fooBarSources - * * @return $this */ public function setFooBarSources(?array $fooBarSources): static { $this->fooBarSources = $fooBarSources; - return $this; } - - /** - * fooBarHiddenSources NodesSources direct field buffer. - * (Virtual field, this var is a buffer) - * - * ForBar hidden nodes field. - * Maecenas sed diam eget risus varius blandit sit amet non magna. - * @var \mock\Entity\NodesSources[]|null - */ - #[Serializer\Exclude] - private ?array $fooBarHiddenSources = null; - /** - * @return \mock\Entity\NodesSources[] fooBarHidden nodes-sources array + * @return \mock\Entity\NodesSources[] */ - #[ - Serializer\Exclude, - SymfonySerializer\Ignore, - Serializer\VirtualProperty, - Serializer\SerializedName("fooBarHidden"), - Serializer\Type("array") - ] + #[JMS\Exclude] + #[Serializer\Ignore] + #[JMS\VirtualProperty] + #[JMS\SerializedName('fooBarHidden')] + #[JMS\Type('array')] public function getFooBarHiddenSources(): array { if (null === $this->fooBarHiddenSources) { @@ -843,44 +820,22 @@ public function getFooBarHiddenSources(): array /** * @param \mock\Entity\NodesSources[]|null $fooBarHiddenSources - * * @return $this */ public function setFooBarHiddenSources(?array $fooBarHiddenSources): static { $this->fooBarHiddenSources = $fooBarHiddenSources; - return $this; } - - /** - * fooBarTypedSources NodesSources direct field buffer. - * (Virtual field, this var is a buffer) - * - * ForBar nodes typed field. - * Default values: MockTwo - * @var \tests\mocks\GeneratedNodesSources\NSMockTwo[]|null - */ - #[ - Serializer\Exclude, - SymfonySerializer\SerializedName(serializedName: "fooBarTyped"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_default", "nodes_sources_nodes"]), - \ApiPlatform\Metadata\ApiProperty(description: "ForBar nodes typed field"), - SymfonySerializer\MaxDepth(2) - ] - private ?array $fooBarTypedSources = null; - /** - * @return \tests\mocks\GeneratedNodesSources\NSMockTwo[] fooBarTyped nodes-sources array + * @return \tests\mocks\GeneratedNodesSources\NSMockTwo[] */ - #[ - Serializer\Groups(["nodes_sources", "nodes_sources_default", "nodes_sources_nodes"]), - Serializer\MaxDepth(2), - Serializer\VirtualProperty, - Serializer\SerializedName("fooBarTyped"), - Serializer\Type("array") - ] + #[JMS\Groups(['nodes_sources', 'nodes_sources_default', 'nodes_sources_nodes'])] + #[JMS\MaxDepth(2)] + #[JMS\VirtualProperty] + #[JMS\SerializedName('fooBarTyped')] + #[JMS\Type('array')] public function getFooBarTypedSources(): array { if (null === $this->fooBarTypedSources) { @@ -900,41 +855,14 @@ public function getFooBarTypedSources(): array /** * @param \tests\mocks\GeneratedNodesSources\NSMockTwo[]|null $fooBarTypedSources - * * @return $this */ public function setFooBarTypedSources(?array $fooBarTypedSources): static { $this->fooBarTypedSources = $fooBarTypedSources; - return $this; } - - /** - * ForBar layout enum. - * Default values: light, dark, transparent - */ - #[ - SymfonySerializer\SerializedName(serializedName: "layout"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_default"]), - \ApiPlatform\Metadata\ApiProperty(description: "ForBar layout enum", schema: ["type" => "string", "enum" => ["light","dark","transparent"], "example" => "light"]), - SymfonySerializer\MaxDepth(2), - ApiFilter(OrmFilter\SearchFilter::class, strategy: "exact"), - ApiFilter(\RZ\Roadiz\CoreBundle\Api\Filter\NotFilter::class), - Gedmo\Versioned, - ORM\Column( - name: "layout", - type: "string", - nullable: true, - length: 11 - ), - Serializer\Groups(["nodes_sources", "nodes_sources_default"]), - Serializer\MaxDepth(2), - Serializer\Type("string") - ] - private ?string $layout = null; - /** * @return string|null */ @@ -944,86 +872,32 @@ public function getLayout(): ?string } /** - * @param string|null $layout - * * @return $this */ public function setLayout(?string $layout): static { $this->layout = null !== $layout ? - (string) $layout : - null; - + (string) $layout : + null; return $this; } - - /** - * For many_to_one field. - * Default values: classname: \MyCustomEntity - * displayable: getName - * @var \MyCustomEntity|null - */ - #[ - SymfonySerializer\SerializedName(serializedName: "fooManyToOne"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_default"]), - \ApiPlatform\Metadata\ApiProperty(description: "For many_to_one field"), - SymfonySerializer\MaxDepth(2), - ORM\ManyToOne(targetEntity: \MyCustomEntity::class), - ORM\JoinColumn(name: "foo_many_to_one_id", referencedColumnName: "id", onDelete: "SET NULL"), - ApiFilter(OrmFilter\SearchFilter::class, strategy: "exact"), - Serializer\Groups(["nodes_sources", "nodes_sources_default"]), - Serializer\MaxDepth(2) - ] - private ?\MyCustomEntity $fooManyToOne = null; - - /** - * @return \MyCustomEntity|null - */ public function getFooManyToOne(): ?\MyCustomEntity { return $this->fooManyToOne; } /** - * @param \MyCustomEntity|null $fooManyToOne * @return $this */ - public function setFooManyToOne(?\MyCustomEntity $fooManyToOne = null): static + public function setFooManyToOne(?\MyCustomEntity $fooManyToOne): static { $this->fooManyToOne = $fooManyToOne; - return $this; } - /** - * For many_to_many field. - * Default values: classname: \MyCustomEntity - * displayable: getName - * orderBy: - * - field: name - * direction: asc - * @var Collection - */ - #[ - SymfonySerializer\SerializedName(serializedName: "fooManyToMany"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_default"]), - \ApiPlatform\Metadata\ApiProperty(description: "For many_to_many field"), - SymfonySerializer\MaxDepth(2), - ORM\ManyToMany(targetEntity: \MyCustomEntity::class), - ORM\JoinTable(name: "node_type_foo_many_to_many"), - ORM\JoinColumn(name: "node_type_id", referencedColumnName: "id", onDelete: "CASCADE"), - ORM\InverseJoinColumn(name: "foo_many_to_many_id", referencedColumnName: "id", onDelete: "CASCADE"), - ORM\OrderBy(["name" => "asc"]), - ApiFilter(OrmFilter\SearchFilter::class, strategy: "exact"), - Serializer\Groups(["nodes_sources", "nodes_sources_default"]), - Serializer\MaxDepth(2) - ] - private Collection $fooManyToMany; - - /** - * @return Collection + * @return \Doctrine\Common\Collections\Collection */ public function getFooManyToMany(): Collection { @@ -1031,7 +905,7 @@ public function getFooManyToMany(): Collection } /** - * @param Collection|\MyCustomEntity[] $fooManyToMany + * @param \Doctrine\Common\Collections\Collection|array<\MyCustomEntity> $fooManyToMany * @return $this */ public function setFooManyToMany(Collection|array $fooManyToMany): static @@ -1041,72 +915,45 @@ public function setFooManyToMany(Collection|array $fooManyToMany): static } else { $this->fooManyToMany = new \Doctrine\Common\Collections\ArrayCollection($fooManyToMany); } - return $this; } - - /** - * For many_to_many proxied field - * - * @var Collection - */ - #[ - Serializer\Exclude, - SymfonySerializer\Ignore, - ORM\OneToMany( - targetEntity: \Themes\MyTheme\Entities\PositionedCity::class, - mappedBy: "nodeSource", - orphanRemoval: true, - cascade: ["persist", "remove"] - ), - ORM\OrderBy(["position" => "ASC"]) - ] - private Collection $fooManyToManyProxiedProxy; - /** - * @return Collection + * @return \Doctrine\Common\Collections\Collection */ public function getFooManyToManyProxiedProxy(): Collection { return $this->fooManyToManyProxiedProxy; } - /** - * @return Collection - */ - #[ - Serializer\Groups(["nodes_sources", "nodes_sources_default"]), - Serializer\MaxDepth(1), - Serializer\VirtualProperty, - Serializer\SerializedName("fooManyToManyProxied"), - SymfonySerializer\SerializedName(serializedName: "fooManyToManyProxied"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_default"]), - SymfonySerializer\MaxDepth(1) - ] - public function getFooManyToManyProxied(): Collection + #[JMS\Groups(['nodes_sources', 'nodes_sources_default'])] + #[JMS\MaxDepth(1)] + #[JMS\VirtualProperty] + #[JMS\SerializedName('fooManyToManyProxied')] + #[Serializer\SerializedName(serializedName: 'fooManyToManyProxied')] + #[Serializer\Groups(['nodes_sources', 'nodes_sources_default'])] + #[Serializer\MaxDepth(1)] + public function getFooManyToManyProxied(): array { return $this->fooManyToManyProxiedProxy->map(function (\Themes\MyTheme\Entities\PositionedCity $proxyEntity) { return $proxyEntity->getCity(); - }); + })->getValues(); } /** - * @param Collection $fooManyToManyProxiedProxy - * @Serializer\VirtualProperty() + * @param \Doctrine\Common\Collections\Collection $fooManyToManyProxiedProxy * @return $this */ public function setFooManyToManyProxiedProxy(Collection $fooManyToManyProxiedProxy): static { $this->fooManyToManyProxiedProxy = $fooManyToManyProxiedProxy; - return $this; } + /** - * @param Collection|array|null $fooManyToManyProxied * @return $this */ - public function setFooManyToManyProxied(Collection|array|null $fooManyToManyProxied = null): static + public function setFooManyToManyProxied(Collection|array|null $fooManyToManyProxied): static { foreach ($this->getFooManyToManyProxiedProxy() as $item) { $item->setNodeSource(null); @@ -1129,11 +976,9 @@ public function setFooManyToManyProxied(Collection|array|null $fooManyToManyProx return $this; } - public function __construct(\mock\Entity\Node $node, \mock\Entity\Translation $translation) { parent::__construct($node, $translation); - $this->eventReferences = new \Doctrine\Common\Collections\ArrayCollection(); $this->eventReferencesProxiedProxy = new \Doctrine\Common\Collections\ArrayCollection(); $this->eventReferencesExcluded = new \Doctrine\Common\Collections\ArrayCollection(); @@ -1141,13 +986,34 @@ public function __construct(\mock\Entity\Node $node, \mock\Entity\Translation $t $this->fooManyToManyProxiedProxy = new \Doctrine\Common\Collections\ArrayCollection(); } - #[ - Serializer\VirtualProperty, - Serializer\Groups(["nodes_sources", "nodes_sources_default"]), - Serializer\SerializedName("@type"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_default"]), - SymfonySerializer\SerializedName(serializedName: "@type") - ] + public function __clone(): void + { + parent::__clone(); + + $eventReferencesProxiedProxyClone = new \Doctrine\Common\Collections\ArrayCollection(); + foreach ($this->eventReferencesProxiedProxy as $item) { + $itemClone = clone $item; + $itemClone->setNodeSource($this); + $eventReferencesProxiedProxyClone->add($itemClone); + $this->objectManager->persist($itemClone); + } + $this->eventReferencesProxiedProxy = $eventReferencesProxiedProxyClone; + + $fooManyToManyProxiedProxyClone = new \Doctrine\Common\Collections\ArrayCollection(); + foreach ($this->fooManyToManyProxiedProxy as $item) { + $itemClone = clone $item; + $itemClone->setNodeSource($this); + $fooManyToManyProxiedProxyClone->add($itemClone); + $this->objectManager->persist($itemClone); + } + $this->fooManyToManyProxiedProxy = $fooManyToManyProxiedProxyClone; + } + + #[JMS\VirtualProperty] + #[JMS\Groups(['nodes_sources', 'nodes_sources_default'])] + #[JMS\SerializedName('@type')] + #[Serializer\Groups(['nodes_sources', 'nodes_sources_default'])] + #[Serializer\SerializedName(serializedName: '@type')] public function getNodeTypeName(): string { return 'Mock'; @@ -1155,9 +1021,9 @@ public function getNodeTypeName(): string /** * $this->nodeType->isReachable() proxy. - * * @return bool Does this nodeSource is reachable over network? */ + #[JMS\VirtualProperty] public function isReachable(): bool { return true; @@ -1165,37 +1031,14 @@ public function isReachable(): bool /** * $this->nodeType->isPublishable() proxy. - * * @return bool Does this nodeSource is publishable with date and time? */ + #[JMS\VirtualProperty] public function isPublishable(): bool { return true; } - public function __clone() - { - parent::__clone(); - - $eventReferencesProxiedProxyClone = new \Doctrine\Common\Collections\ArrayCollection(); - foreach ($this->eventReferencesProxiedProxy as $item) { - $itemClone = clone $item; - $itemClone->setNodeSource($this); - $eventReferencesProxiedProxyClone->add($itemClone); - $this->objectManager->persist($itemClone); - } - $this->eventReferencesProxiedProxy = $eventReferencesProxiedProxyClone; - - $fooManyToManyProxiedProxyClone = new \Doctrine\Common\Collections\ArrayCollection(); - foreach ($this->fooManyToManyProxiedProxy as $item) { - $itemClone = clone $item; - $itemClone->setNodeSource($this); - $fooManyToManyProxiedProxyClone->add($itemClone); - $this->objectManager->persist($itemClone); - } - $this->fooManyToManyProxiedProxy = $fooManyToManyProxiedProxyClone; - } - public function __toString(): string { return '[NSMock] ' . parent::__toString(); diff --git a/lib/EntityGenerator/tests/Mocks/GeneratedNodesSourcesWithRepository/NSMock.php b/lib/EntityGenerator/tests/Mocks/GeneratedNodesSourcesWithRepository/NSMock.php index e91fb63b..dccf9ea6 100644 --- a/lib/EntityGenerator/tests/Mocks/GeneratedNodesSourcesWithRepository/NSMock.php +++ b/lib/EntityGenerator/tests/Mocks/GeneratedNodesSourcesWithRepository/NSMock.php @@ -1,55 +1,431 @@ false])] + #[JMS\Groups(['nodes_sources', 'nodes_sources_default'])] + #[JMS\MaxDepth(1)] + #[JMS\Type('bool')] + private bool $boolIndexed = false; + + /** + * Foo markdown field. + * Maecenas sed diam eget risus varius blandit sit amet non magna. + * Default values: + * allow_h2: false + * allow_h3: false + * allow_h4: false + * allow_h5: false + * allow_h6: false + * allow_bold: true + * allow_italic: true + * allow_blockquote: false + * allow_image: false + * allow_list: false + * allow_nbsp: true + * allow_nb_hyphen: true + * allow_return: true + * allow_link: false + * allow_hr: false + * allow_preview: true + */ + #[Serializer\SerializedName(serializedName: 'fooMarkdown')] + #[Serializer\Groups(['nodes_sources', 'nodes_sources_default'])] + #[ApiProperty(description: 'Foo markdown field: Maecenas sed diam eget risus varius blandit sit amet non magna')] + #[Serializer\MaxDepth(1)] + #[Gedmo\Versioned] + #[ORM\Column(name: 'foo_markdown', type: 'text', nullable: true)] + #[JMS\Groups(['nodes_sources', 'nodes_sources_default'])] + #[JMS\MaxDepth(1)] + #[JMS\Type('string')] + private ?string $fooMarkdown = null; + + /** + * Foo excluded markdown field. + * Maecenas sed diam eget risus varius blandit sit amet non magna. + * Default values: + * allow_h2: false + * allow_h3: false + * allow_h4: false + * allow_h5: false + * allow_h6: false + * allow_bold: true + * allow_italic: true + * allow_blockquote: false + * allow_image: false + * allow_list: false + * allow_nbsp: true + * allow_nb_hyphen: true + * allow_return: true + * allow_link: false + * allow_hr: false + * allow_preview: true + */ + #[Gedmo\Versioned] + #[ORM\Column(name: 'foo_markdown_excluded', type: 'text', nullable: true)] + #[JMS\Exclude] + #[Serializer\Ignore] + private ?string $fooMarkdownExcluded = null; + + /** + * Foo expression excluded decimal. + * Maecenas sed diam eget risus varius blandit sit amet non magna. + */ + #[Serializer\SerializedName(serializedName: 'fooDecimalExcluded')] + #[Serializer\Groups(['nodes_sources', 'nodes_sources_default'])] + #[ApiProperty(description: 'Foo expression excluded decimal: Maecenas sed diam eget risus varius blandit sit amet non magna')] + #[Serializer\MaxDepth(2)] + #[ApiFilter(\ApiPlatform\Doctrine\Orm\Filter\OrderFilter::class)] + #[ApiFilter(\ApiPlatform\Doctrine\Orm\Filter\NumericFilter::class)] + #[ApiFilter(\ApiPlatform\Doctrine\Orm\Filter\RangeFilter::class)] + #[Gedmo\Versioned] + #[ORM\Column(name: 'foo_decimal_excluded', type: 'decimal', nullable: true, precision: 18, scale: 3)] + #[JMS\Groups(['nodes_sources', 'nodes_sources_default'])] + #[JMS\MaxDepth(2)] + #[JMS\Exclude(if: 'object.foo == \'test\'')] + #[JMS\Type('double')] + private int|float|null $fooDecimalExcluded = null; + + /** + * Référence à l'événement. + * Maecenas sed diam eget risus varius blandit sit amet non magna. + * Default values: + * # Entity class name + * classname: \App\Entity\Base\Event + * # Displayable is the method used to display entity name + * displayable: getName + * # Same as Displayable but for a secondary information + * alt_displayable: getSortingFirstDateTime + * # Same as Displayable but for a secondary information + * thumbnail: getMainDocument + * # Searchable entity fields + * searchable: + * - name + * - slug + * # This order will only be used for explorer + * orderBy: + * - field: sortingLastDateTime + * direction: DESC + */ + #[Serializer\SerializedName(serializedName: 'singleEventReference')] + #[Serializer\Groups(['nodes_sources', 'nodes_sources_default'])] + #[ApiProperty(description: 'Référence à l\'événement: Maecenas sed diam eget risus varius blandit sit amet non magna')] + #[Serializer\MaxDepth(2)] + #[ORM\ManyToOne(targetEntity: \App\Entity\Base\Event::class)] + #[ORM\JoinColumn(name: 'single_event_reference_id', referencedColumnName: 'id', onDelete: 'SET NULL')] + #[ApiFilter(\ApiPlatform\Doctrine\Orm\Filter\SearchFilter::class, strategy: 'exact')] + #[JMS\Groups(['nodes_sources', 'nodes_sources_default'])] + #[JMS\MaxDepth(2)] + private ?\App\Entity\Base\Event $singleEventReference = null; + + /** + * Remontée d'événements manuelle. + * Maecenas sed diam eget risus varius blandit sit amet non magna. + * Default values: + * # Entity class name + * classname: \App\Entity\Base\Event + * # Displayable is the method used to display entity name + * displayable: getName + * # Same as Displayable but for a secondary information + * alt_displayable: getSortingFirstDateTime + * # Same as Displayable but for a secondary information + * thumbnail: getMainDocument + * # Searchable entity fields + * searchable: + * - name + * - slug + * # This order will only be used for explorer + * orderBy: + * - field: sortingLastDateTime + * direction: DESC + * @var \Doctrine\Common\Collections\Collection + */ + #[Serializer\SerializedName(serializedName: 'eventReferences')] + #[Serializer\Groups(['nodes_sources', 'nodes_sources_default'])] + #[ApiProperty(description: 'Remontée d\'événements manuelle: Maecenas sed diam eget risus varius blandit sit amet non magna')] + #[Serializer\MaxDepth(2)] + #[ORM\ManyToMany(targetEntity: \App\Entity\Base\Event::class)] + #[ORM\JoinTable(name: 'node_type_event_references')] + #[ORM\JoinColumn(name: 'node_type_id', referencedColumnName: 'id', onDelete: 'CASCADE')] + #[ORM\InverseJoinColumn(name: 'event_references_id', referencedColumnName: 'id', onDelete: 'CASCADE')] + #[ORM\OrderBy(['sortingLastDateTime' => 'DESC'])] + #[ApiFilter(\ApiPlatform\Doctrine\Orm\Filter\SearchFilter::class, strategy: 'exact')] + #[JMS\Groups(['nodes_sources', 'nodes_sources_default'])] + #[JMS\MaxDepth(2)] + private Collection $eventReferences; + + /** + * Buffer var to get referenced entities (documents, nodes, cforms, doctrine entities) + * Remontée d'événements manuelle. + * @var \Doctrine\Common\Collections\Collection + */ + #[JMS\Exclude] + #[Serializer\Ignore] + #[ORM\OneToMany( + targetEntity: \App\Entity\PositionedCity::class, + mappedBy: 'nodeSource', + orphanRemoval: true, + cascade: ['persist', 'remove'], + )] + #[ORM\OrderBy(['position' => 'ASC'])] + private Collection $eventReferencesProxiedProxy; + + /** + * Remontée d'événements manuelle exclue. + * Maecenas sed diam eget risus varius blandit sit amet non magna. + * Default values: + * # Entity class name + * classname: \App\Entity\Base\Event + * # Displayable is the method used to display entity name + * displayable: getName + * # Same as Displayable but for a secondary information + * alt_displayable: getSortingFirstDateTime + * # Same as Displayable but for a secondary information + * thumbnail: getMainDocument + * # Searchable entity fields + * searchable: + * - name + * - slug + * # This order will only be used for explorer + * orderBy: + * - field: sortingLastDateTime + * direction: DESC + * @var \Doctrine\Common\Collections\Collection + */ + #[ORM\ManyToMany(targetEntity: \App\Entity\Base\Event::class)] + #[ORM\JoinTable(name: 'node_type_event_references_excluded')] + #[ORM\JoinColumn(name: 'node_type_id', referencedColumnName: 'id', onDelete: 'CASCADE')] + #[ORM\InverseJoinColumn(name: 'event_references_excluded_id', referencedColumnName: 'id', onDelete: 'CASCADE')] + #[ORM\OrderBy(['sortingLastDateTime' => 'DESC'])] + #[ApiFilter(\ApiPlatform\Doctrine\Orm\Filter\SearchFilter::class, strategy: 'exact')] + #[JMS\Exclude] + #[Serializer\Ignore] + private Collection $eventReferencesExcluded; + + /** + * Bar documents field. + * Maecenas sed diam eget risus varius blandit sit amet non magna. + * (Virtual field, this var is a buffer) + */ + #[JMS\Exclude] + #[Serializer\SerializedName(serializedName: 'bar')] + #[Serializer\Groups(['nodes_sources', 'nodes_sources_default', 'nodes_sources_documents'])] + #[ApiProperty(description: 'Bar documents field: Maecenas sed diam eget risus varius blandit sit amet non magna')] + #[Serializer\MaxDepth(1)] + private ?array $bar = null; + + /** + * Custom forms field. + * (Virtual field, this var is a buffer) + */ + #[JMS\Exclude] + #[Serializer\SerializedName(serializedName: 'theForms')] + #[Serializer\Groups(['nodes_sources', 'nodes_sources_default', 'nodes_sources_custom_forms'])] + #[ApiProperty(description: 'Custom forms field')] + #[Serializer\MaxDepth(2)] + private ?array $theForms = null; + + /** + * fooBarSources NodesSources direct field buffer. + * @var \mock\Entity\NodesSources[]|null + * ForBar nodes field. + * Maecenas sed diam eget risus varius blandit sit amet non magna. + */ + #[JMS\Exclude] + #[Serializer\SerializedName(serializedName: 'fooBar')] + #[Serializer\Groups(['nodes_sources', 'nodes_sources_default', 'nodes_sources_nodes'])] + #[ApiProperty(description: 'ForBar nodes field: Maecenas sed diam eget risus varius blandit sit amet non magna')] + #[Serializer\MaxDepth(2)] + private ?array $fooBarSources = null; + + /** + * fooBarHiddenSources NodesSources direct field buffer. + * @var \mock\Entity\NodesSources[]|null + * ForBar hidden nodes field. + * Maecenas sed diam eget risus varius blandit sit amet non magna. + */ + #[JMS\Exclude] + private ?array $fooBarHiddenSources = null; + + /** + * fooBarTypedSources NodesSources direct field buffer. + * @var \tests\mocks\GeneratedNodesSources\NSMockTwo[]|null + * ForBar nodes typed field. + * Default values: + * MockTwo + */ + #[JMS\Exclude] + #[Serializer\SerializedName(serializedName: 'fooBarTyped')] + #[Serializer\Groups(['nodes_sources', 'nodes_sources_default', 'nodes_sources_nodes'])] + #[ApiProperty(description: 'ForBar nodes typed field')] + #[Serializer\MaxDepth(2)] + private ?array $fooBarTypedSources = null; + + /** + * ForBar layout enum. + * Default values: + * light, dark, transparent + */ + #[Serializer\SerializedName(serializedName: 'layout')] + #[Serializer\Groups(['nodes_sources', 'nodes_sources_default'])] + #[ApiProperty( + description: 'ForBar layout enum', + schema: ['type' => 'string', 'enum' => ['light', 'dark', 'transparent'], 'example' => 'light'], + )] + #[Serializer\MaxDepth(2)] + #[ApiFilter(\ApiPlatform\Doctrine\Orm\Filter\SearchFilter::class, strategy: 'exact')] + #[ApiFilter(\RZ\Roadiz\CoreBundle\Api\Filter\NotFilter::class)] + #[Gedmo\Versioned] + #[ORM\Column(name: 'layout', type: 'string', nullable: true, length: 11)] + #[JMS\Groups(['nodes_sources', 'nodes_sources_default'])] + #[JMS\MaxDepth(2)] + #[JMS\Type('string')] + private ?string $layout = null; + + /** + * For many_to_one field. + * Default values: + * classname: \MyCustomEntity + * displayable: getName + */ + #[Serializer\SerializedName(serializedName: 'fooManyToOne')] + #[Serializer\Groups(['nodes_sources', 'nodes_sources_default'])] + #[ApiProperty(description: 'For many_to_one field')] + #[Serializer\MaxDepth(2)] + #[ORM\ManyToOne(targetEntity: \MyCustomEntity::class)] + #[ORM\JoinColumn(name: 'foo_many_to_one_id', referencedColumnName: 'id', onDelete: 'SET NULL')] + #[ApiFilter(\ApiPlatform\Doctrine\Orm\Filter\SearchFilter::class, strategy: 'exact')] + #[JMS\Groups(['nodes_sources', 'nodes_sources_default'])] + #[JMS\MaxDepth(2)] + private ?\MyCustomEntity $fooManyToOne = null; + + /** + * For many_to_many field. + * Default values: + * classname: \MyCustomEntity + * displayable: getName + * orderBy: + * - field: name + * direction: asc + * @var \Doctrine\Common\Collections\Collection + */ + #[Serializer\SerializedName(serializedName: 'fooManyToMany')] + #[Serializer\Groups(['nodes_sources', 'nodes_sources_default'])] + #[ApiProperty(description: 'For many_to_many field')] + #[Serializer\MaxDepth(2)] + #[ORM\ManyToMany(targetEntity: \MyCustomEntity::class)] + #[ORM\JoinTable(name: 'node_type_foo_many_to_many')] + #[ORM\JoinColumn(name: 'node_type_id', referencedColumnName: 'id', onDelete: 'CASCADE')] + #[ORM\InverseJoinColumn(name: 'foo_many_to_many_id', referencedColumnName: 'id', onDelete: 'CASCADE')] + #[ORM\OrderBy(['name' => 'asc'])] + #[ApiFilter(\ApiPlatform\Doctrine\Orm\Filter\SearchFilter::class, strategy: 'exact')] + #[JMS\Groups(['nodes_sources', 'nodes_sources_default'])] + #[JMS\MaxDepth(2)] + private Collection $fooManyToMany; + + /** + * Buffer var to get referenced entities (documents, nodes, cforms, doctrine entities) + * For many_to_many proxied field. + * @var \Doctrine\Common\Collections\Collection + */ + #[JMS\Exclude] + #[Serializer\Ignore] + #[ORM\OneToMany( + targetEntity: \Themes\MyTheme\Entities\PositionedCity::class, + mappedBy: 'nodeSource', + orphanRemoval: true, + cascade: ['persist', 'remove'], + )] + #[ORM\OrderBy(['position' => 'ASC'])] + private Collection $fooManyToManyProxiedProxy; /** * @return \DateTime|null @@ -60,40 +436,14 @@ public function getFooDatetime(): ?\DateTime } /** - * @param \DateTime|null $fooDatetime - * * @return $this */ public function setFooDatetime(?\DateTime $fooDatetime): static { $this->fooDatetime = $fooDatetime; - return $this; } - - /** - * Foo field. - * Maecenas sed diam eget risus varius blandit sit amet non magna. - */ - #[ - SymfonySerializer\SerializedName(serializedName: "foo"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_default"]), - \ApiPlatform\Metadata\ApiProperty(description: "Foo field: Maecenas sed diam eget risus varius blandit sit amet non magna"), - SymfonySerializer\MaxDepth(1), - Gedmo\Versioned, - ORM\Column( - name: "foo", - type: "string", - nullable: true, - length: 250 - ), - Serializer\Groups(["nodes_sources", "nodes_sources_default"]), - Serializer\MaxDepth(1), - Serializer\Type("string") - ] - private ?string $foo = null; - /** * @return string|null */ @@ -103,44 +453,16 @@ public function getFoo(): ?string } /** - * @param string|null $foo - * * @return $this */ public function setFoo(?string $foo): static { $this->foo = null !== $foo ? - (string) $foo : - null; - + (string) $foo : + null; return $this; } - - /** - * Foo indexed field. - * Maecenas sed diam eget risus varius blandit sit amet non magna. - */ - #[ - SymfonySerializer\SerializedName(serializedName: "fooIndexed"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_default"]), - \ApiPlatform\Metadata\ApiProperty(description: "Foo indexed field: Maecenas sed diam eget risus varius blandit sit amet non magna"), - SymfonySerializer\MaxDepth(1), - ApiFilter(OrmFilter\SearchFilter::class, strategy: "partial"), - ApiFilter(\RZ\Roadiz\CoreBundle\Api\Filter\NotFilter::class), - Gedmo\Versioned, - ORM\Column( - name: "fooIndexed", - type: "string", - nullable: true, - length: 250 - ), - Serializer\Groups(["nodes_sources", "nodes_sources_default"]), - Serializer\MaxDepth(1), - Serializer\Type("string") - ] - private ?string $fooIndexed = null; - /** * @return string|null */ @@ -150,44 +472,16 @@ public function getFooIndexed(): ?string } /** - * @param string|null $fooIndexed - * * @return $this */ public function setFooIndexed(?string $fooIndexed): static { $this->fooIndexed = null !== $fooIndexed ? - (string) $fooIndexed : - null; - + (string) $fooIndexed : + null; return $this; } - - /** - * Bool indexed field. - * Maecenas sed diam eget risus varius blandit sit amet non magna. - */ - #[ - SymfonySerializer\SerializedName(serializedName: "boolIndexed"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_default"]), - \ApiPlatform\Metadata\ApiProperty(description: "Bool indexed field: Maecenas sed diam eget risus varius blandit sit amet non magna"), - SymfonySerializer\MaxDepth(1), - ApiFilter(OrmFilter\OrderFilter::class), - ApiFilter(OrmFilter\BooleanFilter::class), - Gedmo\Versioned, - ORM\Column( - name: "boolIndexed", - type: "boolean", - nullable: false, - options: ["default" => false] - ), - Serializer\Groups(["nodes_sources", "nodes_sources_default"]), - Serializer\MaxDepth(1), - Serializer\Type("bool") - ] - private bool $boolIndexed = false; - /** * @return bool */ @@ -197,51 +491,14 @@ public function getBoolIndexed(): bool } /** - * @param bool $boolIndexed - * * @return $this */ public function setBoolIndexed(bool $boolIndexed): static { $this->boolIndexed = $boolIndexed; - return $this; } - - /** - * Foo markdown field. - * Maecenas sed diam eget risus varius blandit sit amet non magna. - * Default values: allow_h2: false - * allow_h3: false - * allow_h4: false - * allow_h5: false - * allow_h6: false - * allow_bold: true - * allow_italic: true - * allow_blockquote: false - * allow_image: false - * allow_list: false - * allow_nbsp: true - * allow_nb_hyphen: true - * allow_return: true - * allow_link: false - * allow_hr: false - * allow_preview: true - */ - #[ - SymfonySerializer\SerializedName(serializedName: "fooMarkdown"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_default"]), - \ApiPlatform\Metadata\ApiProperty(description: "Foo markdown field: Maecenas sed diam eget risus varius blandit sit amet non magna"), - SymfonySerializer\MaxDepth(1), - Gedmo\Versioned, - ORM\Column(name: "foo_markdown", type: "text", nullable: true), - Serializer\Groups(["nodes_sources", "nodes_sources_default"]), - Serializer\MaxDepth(1), - Serializer\Type("string") - ] - private ?string $fooMarkdown = null; - /** * @return string|null */ @@ -251,48 +508,16 @@ public function getFooMarkdown(): ?string } /** - * @param string|null $fooMarkdown - * * @return $this */ public function setFooMarkdown(?string $fooMarkdown): static { $this->fooMarkdown = null !== $fooMarkdown ? - (string) $fooMarkdown : - null; - + (string) $fooMarkdown : + null; return $this; } - - /** - * Foo excluded markdown field. - * Maecenas sed diam eget risus varius blandit sit amet non magna. - * Default values: allow_h2: false - * allow_h3: false - * allow_h4: false - * allow_h5: false - * allow_h6: false - * allow_bold: true - * allow_italic: true - * allow_blockquote: false - * allow_image: false - * allow_list: false - * allow_nbsp: true - * allow_nb_hyphen: true - * allow_return: true - * allow_link: false - * allow_hr: false - * allow_preview: true - */ - #[ - Gedmo\Versioned, - ORM\Column(name: "foo_markdown_excluded", type: "text", nullable: true), - Serializer\Exclude, - SymfonySerializer\Ignore - ] - private ?string $fooMarkdownExcluded = null; - /** * @return string|null */ @@ -302,47 +527,16 @@ public function getFooMarkdownExcluded(): ?string } /** - * @param string|null $fooMarkdownExcluded - * * @return $this */ public function setFooMarkdownExcluded(?string $fooMarkdownExcluded): static { $this->fooMarkdownExcluded = null !== $fooMarkdownExcluded ? - (string) $fooMarkdownExcluded : - null; - + (string) $fooMarkdownExcluded : + null; return $this; } - - /** - * Foo expression excluded decimal. - * Maecenas sed diam eget risus varius blandit sit amet non magna. - */ - #[ - SymfonySerializer\SerializedName(serializedName: "fooDecimalExcluded"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_default"]), - \ApiPlatform\Metadata\ApiProperty(description: "Foo expression excluded decimal: Maecenas sed diam eget risus varius blandit sit amet non magna"), - SymfonySerializer\MaxDepth(2), - ApiFilter(OrmFilter\OrderFilter::class), - ApiFilter(OrmFilter\NumericFilter::class), - ApiFilter(OrmFilter\RangeFilter::class), - Gedmo\Versioned, - ORM\Column( - name: "foo_decimal_excluded", - type: "decimal", - nullable: true, - precision: 18, - scale: 3 - ), - Serializer\Groups(["nodes_sources", "nodes_sources_default"]), - Serializer\MaxDepth(2), - Serializer\Exclude(if: "object.foo == 'test'"), - Serializer\Type("double") - ] - private int|float|null $fooDecimalExcluded = null; - /** * @return int|float|null */ @@ -352,111 +546,30 @@ public function getFooDecimalExcluded(): int|float|null } /** - * @param int|float|null $fooDecimalExcluded - * * @return $this */ public function setFooDecimalExcluded(int|float|null $fooDecimalExcluded): static { $this->fooDecimalExcluded = $fooDecimalExcluded; - return $this; } - - /** - * Référence à l'événement. - * Maecenas sed diam eget risus varius blandit sit amet non magna. - * Default values: # Entity class name - * classname: \App\Entity\Base\Event - * # Displayable is the method used to display entity name - * displayable: getName - * # Same as Displayable but for a secondary information - * alt_displayable: getSortingFirstDateTime - * # Same as Displayable but for a secondary information - * thumbnail: getMainDocument - * # Searchable entity fields - * searchable: - * - name - * - slug - * # This order will only be used for explorer - * orderBy: - * - field: sortingLastDateTime - * direction: DESC - * @var \App\Entity\Base\Event|null - */ - #[ - SymfonySerializer\SerializedName(serializedName: "singleEventReference"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_default"]), - \ApiPlatform\Metadata\ApiProperty(description: "Référence à l'événement: Maecenas sed diam eget risus varius blandit sit amet non magna"), - SymfonySerializer\MaxDepth(2), - ORM\ManyToOne(targetEntity: \App\Entity\Base\Event::class), - ORM\JoinColumn(name: "single_event_reference_id", referencedColumnName: "id", onDelete: "SET NULL"), - ApiFilter(OrmFilter\SearchFilter::class, strategy: "exact"), - Serializer\Groups(["nodes_sources", "nodes_sources_default"]), - Serializer\MaxDepth(2) - ] - private ?\App\Entity\Base\Event $singleEventReference = null; - - /** - * @return \App\Entity\Base\Event|null - */ public function getSingleEventReference(): ?\App\Entity\Base\Event { return $this->singleEventReference; } /** - * @param \App\Entity\Base\Event|null $singleEventReference * @return $this */ - public function setSingleEventReference(?\App\Entity\Base\Event $singleEventReference = null): static + public function setSingleEventReference(?\App\Entity\Base\Event $singleEventReference): static { $this->singleEventReference = $singleEventReference; - return $this; } - /** - * Remontée d'événements manuelle. - * Maecenas sed diam eget risus varius blandit sit amet non magna. - * Default values: # Entity class name - * classname: \App\Entity\Base\Event - * # Displayable is the method used to display entity name - * displayable: getName - * # Same as Displayable but for a secondary information - * alt_displayable: getSortingFirstDateTime - * # Same as Displayable but for a secondary information - * thumbnail: getMainDocument - * # Searchable entity fields - * searchable: - * - name - * - slug - * # This order will only be used for explorer - * orderBy: - * - field: sortingLastDateTime - * direction: DESC - * @var Collection - */ - #[ - SymfonySerializer\SerializedName(serializedName: "eventReferences"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_default"]), - \ApiPlatform\Metadata\ApiProperty(description: "Remontée d'événements manuelle: Maecenas sed diam eget risus varius blandit sit amet non magna"), - SymfonySerializer\MaxDepth(2), - ORM\ManyToMany(targetEntity: \App\Entity\Base\Event::class), - ORM\JoinTable(name: "node_type_event_references"), - ORM\JoinColumn(name: "node_type_id", referencedColumnName: "id", onDelete: "CASCADE"), - ORM\InverseJoinColumn(name: "event_references_id", referencedColumnName: "id", onDelete: "CASCADE"), - ORM\OrderBy(["sortingLastDateTime" => "DESC"]), - ApiFilter(OrmFilter\SearchFilter::class, strategy: "exact"), - Serializer\Groups(["nodes_sources", "nodes_sources_default"]), - Serializer\MaxDepth(2) - ] - private Collection $eventReferences; - - /** - * @return Collection + * @return \Doctrine\Common\Collections\Collection */ public function getEventReferences(): Collection { @@ -464,7 +577,7 @@ public function getEventReferences(): Collection } /** - * @param Collection|\App\Entity\Base\Event[] $eventReferences + * @param \Doctrine\Common\Collections\Collection|array<\App\Entity\Base\Event> $eventReferences * @return $this */ public function setEventReferences(Collection|array $eventReferences): static @@ -474,72 +587,45 @@ public function setEventReferences(Collection|array $eventReferences): static } else { $this->eventReferences = new \Doctrine\Common\Collections\ArrayCollection($eventReferences); } - return $this; } - - /** - * Remontée d'événements manuelle - * - * @var Collection - */ - #[ - Serializer\Exclude, - SymfonySerializer\Ignore, - ORM\OneToMany( - targetEntity: \App\Entity\PositionedCity::class, - mappedBy: "nodeSource", - orphanRemoval: true, - cascade: ["persist", "remove"] - ), - ORM\OrderBy(["position" => "ASC"]) - ] - private Collection $eventReferencesProxiedProxy; - /** - * @return Collection + * @return \Doctrine\Common\Collections\Collection */ public function getEventReferencesProxiedProxy(): Collection { return $this->eventReferencesProxiedProxy; } - /** - * @return Collection - */ - #[ - Serializer\Groups(["nodes_sources", "nodes_sources_default"]), - Serializer\MaxDepth(2), - Serializer\VirtualProperty, - Serializer\SerializedName("eventReferencesProxied"), - SymfonySerializer\SerializedName(serializedName: "eventReferencesProxied"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_default"]), - SymfonySerializer\MaxDepth(2) - ] - public function getEventReferencesProxied(): Collection + #[JMS\Groups(['nodes_sources', 'nodes_sources_default'])] + #[JMS\MaxDepth(2)] + #[JMS\VirtualProperty] + #[JMS\SerializedName('eventReferencesProxied')] + #[Serializer\SerializedName(serializedName: 'eventReferencesProxied')] + #[Serializer\Groups(['nodes_sources', 'nodes_sources_default'])] + #[Serializer\MaxDepth(2)] + public function getEventReferencesProxied(): array { return $this->eventReferencesProxiedProxy->map(function (\App\Entity\PositionedCity $proxyEntity) { return $proxyEntity->getCity(); - }); + })->getValues(); } /** - * @param Collection $eventReferencesProxiedProxy - * @Serializer\VirtualProperty() + * @param \Doctrine\Common\Collections\Collection $eventReferencesProxiedProxy * @return $this */ public function setEventReferencesProxiedProxy(Collection $eventReferencesProxiedProxy): static { $this->eventReferencesProxiedProxy = $eventReferencesProxiedProxy; - return $this; } + /** - * @param Collection|array|null $eventReferencesProxied * @return $this */ - public function setEventReferencesProxied(Collection|array|null $eventReferencesProxied = null): static + public function setEventReferencesProxied(Collection|array|null $eventReferencesProxied): static { foreach ($this->getEventReferencesProxiedProxy() as $item) { $item->setNodeSource(null); @@ -562,42 +648,8 @@ public function setEventReferencesProxied(Collection|array|null $eventReferences return $this; } - - /** - * Remontée d'événements manuelle exclue. - * Maecenas sed diam eget risus varius blandit sit amet non magna. - * Default values: # Entity class name - * classname: \App\Entity\Base\Event - * # Displayable is the method used to display entity name - * displayable: getName - * # Same as Displayable but for a secondary information - * alt_displayable: getSortingFirstDateTime - * # Same as Displayable but for a secondary information - * thumbnail: getMainDocument - * # Searchable entity fields - * searchable: - * - name - * - slug - * # This order will only be used for explorer - * orderBy: - * - field: sortingLastDateTime - * direction: DESC - * @var Collection - */ - #[ - ORM\ManyToMany(targetEntity: \App\Entity\Base\Event::class), - ORM\JoinTable(name: "node_type_event_references_excluded"), - ORM\JoinColumn(name: "node_type_id", referencedColumnName: "id", onDelete: "CASCADE"), - ORM\InverseJoinColumn(name: "event_references_excluded_id", referencedColumnName: "id", onDelete: "CASCADE"), - ORM\OrderBy(["sortingLastDateTime" => "DESC"]), - ApiFilter(OrmFilter\SearchFilter::class, strategy: "exact"), - Serializer\Exclude, - SymfonySerializer\Ignore - ] - private Collection $eventReferencesExcluded; - /** - * @return Collection + * @return \Doctrine\Common\Collections\Collection */ public function getEventReferencesExcluded(): Collection { @@ -605,7 +657,7 @@ public function getEventReferencesExcluded(): Collection } /** - * @param Collection|\App\Entity\Base\Event[] $eventReferencesExcluded + * @param \Doctrine\Common\Collections\Collection|array<\App\Entity\Base\Event> $eventReferencesExcluded * @return $this */ public function setEventReferencesExcluded(Collection|array $eventReferencesExcluded): static @@ -615,36 +667,17 @@ public function setEventReferencesExcluded(Collection|array $eventReferencesExcl } else { $this->eventReferencesExcluded = new \Doctrine\Common\Collections\ArrayCollection($eventReferencesExcluded); } - return $this; } - - /** - * Bar documents field. - * Maecenas sed diam eget risus varius blandit sit amet non magna. - * - * (Virtual field, this var is a buffer) - */ - #[ - Serializer\Exclude, - SymfonySerializer\SerializedName(serializedName: "bar"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_default", "nodes_sources_documents"]), - \ApiPlatform\Metadata\ApiProperty(description: "Bar documents field: Maecenas sed diam eget risus varius blandit sit amet non magna"), - SymfonySerializer\MaxDepth(1) - ] - private ?array $bar = null; - /** - * @return \mock\Entity\Document[] Documents array + * @return \mock\Entity\Document[] */ - #[ - Serializer\Groups(["nodes_sources", "nodes_sources_default", "nodes_sources_documents"]), - Serializer\MaxDepth(1), - Serializer\VirtualProperty, - Serializer\SerializedName("bar"), - Serializer\Type("array") - ] + #[JMS\Groups(['nodes_sources', 'nodes_sources_default', 'nodes_sources_documents'])] + #[JMS\MaxDepth(1)] + #[JMS\VirtualProperty] + #[JMS\SerializedName('bar')] + #[JMS\Type('array')] public function getBar(): array { if (null === $this->bar) { @@ -663,51 +696,33 @@ public function getBar(): array } /** - * @param \mock\Entity\Document $document - * * @return $this */ public function addBar(\mock\Entity\Document $document): static { - if (null !== $this->objectManager) { - $nodeSourceDocument = new \mock\Entity\NodesSourcesDocument( - $this, - $document - ); - $nodeSourceDocument->setFieldName('bar'); - if (!$this->hasNodesSourcesDocuments($nodeSourceDocument)) { - $this->objectManager->persist($nodeSourceDocument); - $this->addDocumentsByFields($nodeSourceDocument); - $this->bar = null; - } + if (null === $this->objectManager) { + return $this; + } + $nodeSourceDocument = new \mock\Entity\NodesSourcesDocument( + $this, + $document + ); + $nodeSourceDocument->setFieldName('bar'); + if (!$this->hasNodesSourcesDocuments($nodeSourceDocument)) { + $this->objectManager->persist($nodeSourceDocument); + $this->addDocumentsByFields($nodeSourceDocument); + $this->bar = null; } return $this; } - - /** - * Custom forms field. - * - * (Virtual field, this var is a buffer) - */ - #[ - Serializer\Exclude, - SymfonySerializer\SerializedName(serializedName: "theForms"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_default", "nodes_sources_custom_forms"]), - \ApiPlatform\Metadata\ApiProperty(description: "Custom forms field"), - SymfonySerializer\MaxDepth(2) - ] - private ?array $theForms = null; - /** * @return \mock\Entity\CustomForm[] CustomForm array */ - #[ - Serializer\Groups(["nodes_sources", "nodes_sources_default", "nodes_sources_custom_forms"]), - Serializer\MaxDepth(2), - Serializer\VirtualProperty, - Serializer\SerializedName("theForms") - ] + #[JMS\Groups(['nodes_sources', 'nodes_sources_default', 'nodes_sources_custom_forms'])] + #[JMS\MaxDepth(2)] + #[JMS\VirtualProperty] + #[JMS\SerializedName('theForms')] public function getTheForms(): array { if (null === $this->theForms) { @@ -726,8 +741,6 @@ public function getTheForms(): array } /** - * @param \mock\Entity\CustomForm $customForm - * * @return $this */ public function addTheForms(\mock\Entity\CustomForm $customForm): static @@ -745,34 +758,14 @@ public function addTheForms(\mock\Entity\CustomForm $customForm): static return $this; } - - /** - * fooBarSources NodesSources direct field buffer. - * (Virtual field, this var is a buffer) - * - * ForBar nodes field. - * Maecenas sed diam eget risus varius blandit sit amet non magna. - * @var \mock\Entity\NodesSources[]|null - */ - #[ - Serializer\Exclude, - SymfonySerializer\SerializedName(serializedName: "fooBar"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_default", "nodes_sources_nodes"]), - \ApiPlatform\Metadata\ApiProperty(description: "ForBar nodes field: Maecenas sed diam eget risus varius blandit sit amet non magna"), - SymfonySerializer\MaxDepth(2) - ] - private ?array $fooBarSources = null; - /** - * @return \mock\Entity\NodesSources[] fooBar nodes-sources array + * @return \mock\Entity\NodesSources[] */ - #[ - Serializer\Groups(["nodes_sources", "nodes_sources_default", "nodes_sources_nodes"]), - Serializer\MaxDepth(2), - Serializer\VirtualProperty, - Serializer\SerializedName("fooBar"), - Serializer\Type("array") - ] + #[JMS\Groups(['nodes_sources', 'nodes_sources_default', 'nodes_sources_nodes'])] + #[JMS\MaxDepth(2)] + #[JMS\VirtualProperty] + #[JMS\SerializedName('fooBar')] + #[JMS\Type('array')] public function getFooBarSources(): array { if (null === $this->fooBarSources) { @@ -792,38 +785,22 @@ public function getFooBarSources(): array /** * @param \mock\Entity\NodesSources[]|null $fooBarSources - * * @return $this */ public function setFooBarSources(?array $fooBarSources): static { $this->fooBarSources = $fooBarSources; - return $this; } - - /** - * fooBarHiddenSources NodesSources direct field buffer. - * (Virtual field, this var is a buffer) - * - * ForBar hidden nodes field. - * Maecenas sed diam eget risus varius blandit sit amet non magna. - * @var \mock\Entity\NodesSources[]|null - */ - #[Serializer\Exclude] - private ?array $fooBarHiddenSources = null; - /** - * @return \mock\Entity\NodesSources[] fooBarHidden nodes-sources array + * @return \mock\Entity\NodesSources[] */ - #[ - Serializer\Exclude, - SymfonySerializer\Ignore, - Serializer\VirtualProperty, - Serializer\SerializedName("fooBarHidden"), - Serializer\Type("array") - ] + #[JMS\Exclude] + #[Serializer\Ignore] + #[JMS\VirtualProperty] + #[JMS\SerializedName('fooBarHidden')] + #[JMS\Type('array')] public function getFooBarHiddenSources(): array { if (null === $this->fooBarHiddenSources) { @@ -843,44 +820,22 @@ public function getFooBarHiddenSources(): array /** * @param \mock\Entity\NodesSources[]|null $fooBarHiddenSources - * * @return $this */ public function setFooBarHiddenSources(?array $fooBarHiddenSources): static { $this->fooBarHiddenSources = $fooBarHiddenSources; - return $this; } - - /** - * fooBarTypedSources NodesSources direct field buffer. - * (Virtual field, this var is a buffer) - * - * ForBar nodes typed field. - * Default values: MockTwo - * @var \tests\mocks\GeneratedNodesSources\NSMockTwo[]|null - */ - #[ - Serializer\Exclude, - SymfonySerializer\SerializedName(serializedName: "fooBarTyped"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_default", "nodes_sources_nodes"]), - \ApiPlatform\Metadata\ApiProperty(description: "ForBar nodes typed field"), - SymfonySerializer\MaxDepth(2) - ] - private ?array $fooBarTypedSources = null; - /** - * @return \tests\mocks\GeneratedNodesSources\NSMockTwo[] fooBarTyped nodes-sources array + * @return \tests\mocks\GeneratedNodesSources\NSMockTwo[] */ - #[ - Serializer\Groups(["nodes_sources", "nodes_sources_default", "nodes_sources_nodes"]), - Serializer\MaxDepth(2), - Serializer\VirtualProperty, - Serializer\SerializedName("fooBarTyped"), - Serializer\Type("array") - ] + #[JMS\Groups(['nodes_sources', 'nodes_sources_default', 'nodes_sources_nodes'])] + #[JMS\MaxDepth(2)] + #[JMS\VirtualProperty] + #[JMS\SerializedName('fooBarTyped')] + #[JMS\Type('array')] public function getFooBarTypedSources(): array { if (null === $this->fooBarTypedSources) { @@ -900,41 +855,14 @@ public function getFooBarTypedSources(): array /** * @param \tests\mocks\GeneratedNodesSources\NSMockTwo[]|null $fooBarTypedSources - * * @return $this */ public function setFooBarTypedSources(?array $fooBarTypedSources): static { $this->fooBarTypedSources = $fooBarTypedSources; - return $this; } - - /** - * ForBar layout enum. - * Default values: light, dark, transparent - */ - #[ - SymfonySerializer\SerializedName(serializedName: "layout"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_default"]), - \ApiPlatform\Metadata\ApiProperty(description: "ForBar layout enum", schema: ["type" => "string", "enum" => ["light","dark","transparent"], "example" => "light"]), - SymfonySerializer\MaxDepth(2), - ApiFilter(OrmFilter\SearchFilter::class, strategy: "exact"), - ApiFilter(\RZ\Roadiz\CoreBundle\Api\Filter\NotFilter::class), - Gedmo\Versioned, - ORM\Column( - name: "layout", - type: "string", - nullable: true, - length: 11 - ), - Serializer\Groups(["nodes_sources", "nodes_sources_default"]), - Serializer\MaxDepth(2), - Serializer\Type("string") - ] - private ?string $layout = null; - /** * @return string|null */ @@ -944,86 +872,32 @@ public function getLayout(): ?string } /** - * @param string|null $layout - * * @return $this */ public function setLayout(?string $layout): static { $this->layout = null !== $layout ? - (string) $layout : - null; - + (string) $layout : + null; return $this; } - - /** - * For many_to_one field. - * Default values: classname: \MyCustomEntity - * displayable: getName - * @var \MyCustomEntity|null - */ - #[ - SymfonySerializer\SerializedName(serializedName: "fooManyToOne"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_default"]), - \ApiPlatform\Metadata\ApiProperty(description: "For many_to_one field"), - SymfonySerializer\MaxDepth(2), - ORM\ManyToOne(targetEntity: \MyCustomEntity::class), - ORM\JoinColumn(name: "foo_many_to_one_id", referencedColumnName: "id", onDelete: "SET NULL"), - ApiFilter(OrmFilter\SearchFilter::class, strategy: "exact"), - Serializer\Groups(["nodes_sources", "nodes_sources_default"]), - Serializer\MaxDepth(2) - ] - private ?\MyCustomEntity $fooManyToOne = null; - - /** - * @return \MyCustomEntity|null - */ public function getFooManyToOne(): ?\MyCustomEntity { return $this->fooManyToOne; } /** - * @param \MyCustomEntity|null $fooManyToOne * @return $this */ - public function setFooManyToOne(?\MyCustomEntity $fooManyToOne = null): static + public function setFooManyToOne(?\MyCustomEntity $fooManyToOne): static { $this->fooManyToOne = $fooManyToOne; - return $this; } - /** - * For many_to_many field. - * Default values: classname: \MyCustomEntity - * displayable: getName - * orderBy: - * - field: name - * direction: asc - * @var Collection - */ - #[ - SymfonySerializer\SerializedName(serializedName: "fooManyToMany"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_default"]), - \ApiPlatform\Metadata\ApiProperty(description: "For many_to_many field"), - SymfonySerializer\MaxDepth(2), - ORM\ManyToMany(targetEntity: \MyCustomEntity::class), - ORM\JoinTable(name: "node_type_foo_many_to_many"), - ORM\JoinColumn(name: "node_type_id", referencedColumnName: "id", onDelete: "CASCADE"), - ORM\InverseJoinColumn(name: "foo_many_to_many_id", referencedColumnName: "id", onDelete: "CASCADE"), - ORM\OrderBy(["name" => "asc"]), - ApiFilter(OrmFilter\SearchFilter::class, strategy: "exact"), - Serializer\Groups(["nodes_sources", "nodes_sources_default"]), - Serializer\MaxDepth(2) - ] - private Collection $fooManyToMany; - - /** - * @return Collection + * @return \Doctrine\Common\Collections\Collection */ public function getFooManyToMany(): Collection { @@ -1031,7 +905,7 @@ public function getFooManyToMany(): Collection } /** - * @param Collection|\MyCustomEntity[] $fooManyToMany + * @param \Doctrine\Common\Collections\Collection|array<\MyCustomEntity> $fooManyToMany * @return $this */ public function setFooManyToMany(Collection|array $fooManyToMany): static @@ -1041,72 +915,45 @@ public function setFooManyToMany(Collection|array $fooManyToMany): static } else { $this->fooManyToMany = new \Doctrine\Common\Collections\ArrayCollection($fooManyToMany); } - return $this; } - - /** - * For many_to_many proxied field - * - * @var Collection - */ - #[ - Serializer\Exclude, - SymfonySerializer\Ignore, - ORM\OneToMany( - targetEntity: \Themes\MyTheme\Entities\PositionedCity::class, - mappedBy: "nodeSource", - orphanRemoval: true, - cascade: ["persist", "remove"] - ), - ORM\OrderBy(["position" => "ASC"]) - ] - private Collection $fooManyToManyProxiedProxy; - /** - * @return Collection + * @return \Doctrine\Common\Collections\Collection */ public function getFooManyToManyProxiedProxy(): Collection { return $this->fooManyToManyProxiedProxy; } - /** - * @return Collection - */ - #[ - Serializer\Groups(["nodes_sources", "nodes_sources_default"]), - Serializer\MaxDepth(1), - Serializer\VirtualProperty, - Serializer\SerializedName("fooManyToManyProxied"), - SymfonySerializer\SerializedName(serializedName: "fooManyToManyProxied"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_default"]), - SymfonySerializer\MaxDepth(1) - ] - public function getFooManyToManyProxied(): Collection + #[JMS\Groups(['nodes_sources', 'nodes_sources_default'])] + #[JMS\MaxDepth(1)] + #[JMS\VirtualProperty] + #[JMS\SerializedName('fooManyToManyProxied')] + #[Serializer\SerializedName(serializedName: 'fooManyToManyProxied')] + #[Serializer\Groups(['nodes_sources', 'nodes_sources_default'])] + #[Serializer\MaxDepth(1)] + public function getFooManyToManyProxied(): array { return $this->fooManyToManyProxiedProxy->map(function (\Themes\MyTheme\Entities\PositionedCity $proxyEntity) { return $proxyEntity->getCity(); - }); + })->getValues(); } /** - * @param Collection $fooManyToManyProxiedProxy - * @Serializer\VirtualProperty() + * @param \Doctrine\Common\Collections\Collection $fooManyToManyProxiedProxy * @return $this */ public function setFooManyToManyProxiedProxy(Collection $fooManyToManyProxiedProxy): static { $this->fooManyToManyProxiedProxy = $fooManyToManyProxiedProxy; - return $this; } + /** - * @param Collection|array|null $fooManyToManyProxied * @return $this */ - public function setFooManyToManyProxied(Collection|array|null $fooManyToManyProxied = null): static + public function setFooManyToManyProxied(Collection|array|null $fooManyToManyProxied): static { foreach ($this->getFooManyToManyProxiedProxy() as $item) { $item->setNodeSource(null); @@ -1129,11 +976,9 @@ public function setFooManyToManyProxied(Collection|array|null $fooManyToManyProx return $this; } - public function __construct(\mock\Entity\Node $node, \mock\Entity\Translation $translation) { parent::__construct($node, $translation); - $this->eventReferences = new \Doctrine\Common\Collections\ArrayCollection(); $this->eventReferencesProxiedProxy = new \Doctrine\Common\Collections\ArrayCollection(); $this->eventReferencesExcluded = new \Doctrine\Common\Collections\ArrayCollection(); @@ -1141,13 +986,34 @@ public function __construct(\mock\Entity\Node $node, \mock\Entity\Translation $t $this->fooManyToManyProxiedProxy = new \Doctrine\Common\Collections\ArrayCollection(); } - #[ - Serializer\VirtualProperty, - Serializer\Groups(["nodes_sources", "nodes_sources_default"]), - Serializer\SerializedName("@type"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_default"]), - SymfonySerializer\SerializedName(serializedName: "@type") - ] + public function __clone(): void + { + parent::__clone(); + + $eventReferencesProxiedProxyClone = new \Doctrine\Common\Collections\ArrayCollection(); + foreach ($this->eventReferencesProxiedProxy as $item) { + $itemClone = clone $item; + $itemClone->setNodeSource($this); + $eventReferencesProxiedProxyClone->add($itemClone); + $this->objectManager->persist($itemClone); + } + $this->eventReferencesProxiedProxy = $eventReferencesProxiedProxyClone; + + $fooManyToManyProxiedProxyClone = new \Doctrine\Common\Collections\ArrayCollection(); + foreach ($this->fooManyToManyProxiedProxy as $item) { + $itemClone = clone $item; + $itemClone->setNodeSource($this); + $fooManyToManyProxiedProxyClone->add($itemClone); + $this->objectManager->persist($itemClone); + } + $this->fooManyToManyProxiedProxy = $fooManyToManyProxiedProxyClone; + } + + #[JMS\VirtualProperty] + #[JMS\Groups(['nodes_sources', 'nodes_sources_default'])] + #[JMS\SerializedName('@type')] + #[Serializer\Groups(['nodes_sources', 'nodes_sources_default'])] + #[Serializer\SerializedName(serializedName: '@type')] public function getNodeTypeName(): string { return 'Mock'; @@ -1155,9 +1021,9 @@ public function getNodeTypeName(): string /** * $this->nodeType->isReachable() proxy. - * * @return bool Does this nodeSource is reachable over network? */ + #[JMS\VirtualProperty] public function isReachable(): bool { return true; @@ -1165,37 +1031,14 @@ public function isReachable(): bool /** * $this->nodeType->isPublishable() proxy. - * * @return bool Does this nodeSource is publishable with date and time? */ + #[JMS\VirtualProperty] public function isPublishable(): bool { return true; } - public function __clone() - { - parent::__clone(); - - $eventReferencesProxiedProxyClone = new \Doctrine\Common\Collections\ArrayCollection(); - foreach ($this->eventReferencesProxiedProxy as $item) { - $itemClone = clone $item; - $itemClone->setNodeSource($this); - $eventReferencesProxiedProxyClone->add($itemClone); - $this->objectManager->persist($itemClone); - } - $this->eventReferencesProxiedProxy = $eventReferencesProxiedProxyClone; - - $fooManyToManyProxiedProxyClone = new \Doctrine\Common\Collections\ArrayCollection(); - foreach ($this->fooManyToManyProxiedProxy as $item) { - $itemClone = clone $item; - $itemClone->setNodeSource($this); - $fooManyToManyProxiedProxyClone->add($itemClone); - $this->objectManager->persist($itemClone); - } - $this->fooManyToManyProxiedProxy = $fooManyToManyProxiedProxyClone; - } - public function __toString(): string { return '[NSMock] ' . parent::__toString(); diff --git a/lib/EntityGenerator/tests/Mocks/GeneratedNodesSourcesWithRepository/Repository/NSMockRepository.php b/lib/EntityGenerator/tests/Mocks/GeneratedNodesSourcesWithRepository/Repository/NSMockRepository.php index 9f20bbac..3ad1e9ce 100644 --- a/lib/EntityGenerator/tests/Mocks/GeneratedNodesSourcesWithRepository/Repository/NSMockRepository.php +++ b/lib/EntityGenerator/tests/Mocks/GeneratedNodesSourcesWithRepository/Repository/NSMockRepository.php @@ -1,36 +1,38 @@ - * - * @method \RZ\Roadiz\EntityGenerator\Tests\Mocks\GeneratedNodesSourcesWithRepository\NSMock|null find($id, $lockMode = null, $lockVersion = null) - * @method \RZ\Roadiz\EntityGenerator\Tests\Mocks\GeneratedNodesSourcesWithRepository\NSMock|null findOneBy(array $criteria, array $orderBy = null) - * @method \RZ\Roadiz\EntityGenerator\Tests\Mocks\GeneratedNodesSourcesWithRepository\NSMock[] findAll() - * @method \RZ\Roadiz\EntityGenerator\Tests\Mocks\GeneratedNodesSourcesWithRepository\NSMock[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) + * @extends NodesSourcesRepository + * @method NSMock|null find($id, $lockMode = null, $lockVersion = null) + * @method NSMock|null findOneBy(array $criteria, array $orderBy = null) + * @method NSMock[] findAll() + * @method NSMock[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) */ -class NSMockRepository extends \RZ\Roadiz\CoreBundle\Repository\NodesSourcesRepository +final class NSMockRepository extends NodesSourcesRepository { public function __construct( ManagerRegistry $registry, PreviewResolverInterface $previewResolver, EventDispatcherInterface $dispatcher, Security $security, - ?NodeSourceSearchHandlerInterface $nodeSourceSearchHandler + ?NodeSourceSearchHandlerInterface $nodeSourceSearchHandler, ) { - parent::__construct($registry, $previewResolver, $dispatcher, $security, $nodeSourceSearchHandler, \RZ\Roadiz\EntityGenerator\Tests\Mocks\GeneratedNodesSourcesWithRepository\NSMock::class); + parent::__construct($registry, $previewResolver, $dispatcher, $security, $nodeSourceSearchHandler, NSMock::class); } } diff --git a/lib/RoadizCoreBundle/src/CustomForm/Message/Handler/CustomFormAnswerNotifyMessageHandler.php b/lib/RoadizCoreBundle/src/CustomForm/Message/Handler/CustomFormAnswerNotifyMessageHandler.php index abdc481f..2e03ac0f 100644 --- a/lib/RoadizCoreBundle/src/CustomForm/Message/Handler/CustomFormAnswerNotifyMessageHandler.php +++ b/lib/RoadizCoreBundle/src/CustomForm/Message/Handler/CustomFormAnswerNotifyMessageHandler.php @@ -22,14 +22,14 @@ use Twig\Error\SyntaxError; #[AsMessageHandler] -final class CustomFormAnswerNotifyMessageHandler +final readonly class CustomFormAnswerNotifyMessageHandler { public function __construct( - private readonly ManagerRegistry $managerRegistry, - private readonly EmailManagerFactory $emailManagerFactory, - private readonly Settings $settingsBag, - private readonly FilesystemOperator $documentsStorage, - private readonly LoggerInterface $messengerLogger, + private ManagerRegistry $managerRegistry, + private EmailManagerFactory $emailManagerFactory, + private Settings $settingsBag, + private FilesystemOperator $documentsStorage, + private LoggerInterface $messengerLogger, ) { } diff --git a/src/GeneratedEntity/NSArticle.php b/src/GeneratedEntity/NSArticle.php index 5405d278..2c54333b 100644 --- a/src/GeneratedEntity/NSArticle.php +++ b/src/GeneratedEntity/NSArticle.php @@ -1,51 +1,97 @@ content = null !== $content ? - (string) $content : - null; - + (string) $content : + null; return $this; } - - /** - * Secret realm_b. - */ - #[ - SymfonySerializer\SerializedName(serializedName: "realmBSecret"), - SymfonySerializer\Groups(["realm_b"]), - \ApiPlatform\Metadata\ApiProperty(description: "Secret realm_b"), - SymfonySerializer\MaxDepth(2), - Gedmo\Versioned, - ORM\Column( - name: "realm_b_secret", - type: "string", - nullable: true, - length: 250 - ), - Serializer\Groups(["realm_b"]), - Serializer\MaxDepth(2), - Serializer\Type("string") - ] - private ?string $realmBSecret = null; - /** * @return string|null */ @@ -99,41 +120,16 @@ public function getRealmBSecret(): ?string } /** - * @param string|null $realmBSecret - * * @return $this */ public function setRealmBSecret(?string $realmBSecret): static { $this->realmBSecret = null !== $realmBSecret ? - (string) $realmBSecret : - null; - + (string) $realmBSecret : + null; return $this; } - - /** - * Secret realm_a. - */ - #[ - SymfonySerializer\SerializedName(serializedName: "realmASecret"), - SymfonySerializer\Groups(["realm_a"]), - \ApiPlatform\Metadata\ApiProperty(description: "Secret realm_a"), - SymfonySerializer\MaxDepth(2), - Gedmo\Versioned, - ORM\Column( - name: "realm_a_secret", - type: "string", - nullable: true, - length: 250 - ), - Serializer\Groups(["realm_a"]), - Serializer\MaxDepth(2), - Serializer\Type("string") - ] - private ?string $realmASecret = null; - /** * @return string|null */ @@ -143,38 +139,16 @@ public function getRealmASecret(): ?string } /** - * @param string|null $realmASecret - * * @return $this */ public function setRealmASecret(?string $realmASecret): static { $this->realmASecret = null !== $realmASecret ? - (string) $realmASecret : - null; - + (string) $realmASecret : + null; return $this; } - - /** - * Date de dépublication. - */ - #[ - SymfonySerializer\SerializedName(serializedName: "unpublishedAt"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_default"]), - \ApiPlatform\Metadata\ApiProperty(description: "Date de dépublication"), - SymfonySerializer\MaxDepth(2), - ApiFilter(OrmFilter\OrderFilter::class), - ApiFilter(OrmFilter\DateFilter::class), - Gedmo\Versioned, - ORM\Column(name: "unpublished_at", type: "datetime", nullable: true), - Serializer\Groups(["nodes_sources", "nodes_sources_default"]), - Serializer\MaxDepth(2), - Serializer\Type("DateTime") - ] - private ?\DateTime $unpublishedAt = null; - /** * @return \DateTime|null */ @@ -184,39 +158,14 @@ public function getUnpublishedAt(): ?\DateTime } /** - * @param \DateTime|null $unpublishedAt - * * @return $this */ public function setUnpublishedAt(?\DateTime $unpublishedAt): static { $this->unpublishedAt = $unpublishedAt; - return $this; } - - /** - * Only on web response. - */ - #[ - SymfonySerializer\SerializedName(serializedName: "onlyOnWebresponse"), - SymfonySerializer\Groups(["article_get_by_path"]), - \ApiPlatform\Metadata\ApiProperty(description: "Only on web response"), - SymfonySerializer\MaxDepth(2), - Gedmo\Versioned, - ORM\Column( - name: "only_on_webresponse", - type: "string", - nullable: true, - length: 250 - ), - Serializer\Groups(["article_get_by_path"]), - Serializer\MaxDepth(2), - Serializer\Type("string") - ] - private ?string $onlyOnWebresponse = null; - /** * @return string|null */ @@ -226,27 +175,21 @@ public function getOnlyOnWebresponse(): ?string } /** - * @param string|null $onlyOnWebresponse - * * @return $this */ public function setOnlyOnWebresponse(?string $onlyOnWebresponse): static { $this->onlyOnWebresponse = null !== $onlyOnWebresponse ? - (string) $onlyOnWebresponse : - null; - + (string) $onlyOnWebresponse : + null; return $this; } - - #[ - Serializer\VirtualProperty, - Serializer\Groups(["nodes_sources", "nodes_sources_default"]), - Serializer\SerializedName("@type"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_default"]), - SymfonySerializer\SerializedName(serializedName: "@type") - ] + #[JMS\VirtualProperty] + #[JMS\Groups(['nodes_sources', 'nodes_sources_default'])] + #[JMS\SerializedName('@type')] + #[Serializer\Groups(['nodes_sources', 'nodes_sources_default'])] + #[Serializer\SerializedName(serializedName: '@type')] public function getNodeTypeName(): string { return 'Article'; @@ -254,9 +197,9 @@ public function getNodeTypeName(): string /** * $this->nodeType->isReachable() proxy. - * * @return bool Does this nodeSource is reachable over network? */ + #[JMS\VirtualProperty] public function isReachable(): bool { return true; @@ -264,9 +207,9 @@ public function isReachable(): bool /** * $this->nodeType->isPublishable() proxy. - * * @return bool Does this nodeSource is publishable with date and time? */ + #[JMS\VirtualProperty] public function isPublishable(): bool { return true; diff --git a/src/GeneratedEntity/NSArticleContainer.php b/src/GeneratedEntity/NSArticleContainer.php index 04996420..d5fafb92 100644 --- a/src/GeneratedEntity/NSArticleContainer.php +++ b/src/GeneratedEntity/NSArticleContainer.php @@ -1,40 +1,38 @@ nodeType->isReachable() proxy. - * * @return bool Does this nodeSource is reachable over network? */ + #[JMS\VirtualProperty] public function isReachable(): bool { return true; @@ -52,9 +50,9 @@ public function isReachable(): bool /** * $this->nodeType->isPublishable() proxy. - * * @return bool Does this nodeSource is publishable with date and time? */ + #[JMS\VirtualProperty] public function isPublishable(): bool { return false; diff --git a/src/GeneratedEntity/NSArticleFeedBlock.php b/src/GeneratedEntity/NSArticleFeedBlock.php index 6386860d..40275010 100644 --- a/src/GeneratedEntity/NSArticleFeedBlock.php +++ b/src/GeneratedEntity/NSArticleFeedBlock.php @@ -1,47 +1,43 @@ listingCount = null !== $listingCount ? - (int) $listingCount : - null; - + (int) $listingCount : + null; return $this; } - - #[ - Serializer\VirtualProperty, - Serializer\Groups(["nodes_sources", "nodes_sources_default"]), - Serializer\SerializedName("@type"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_default"]), - SymfonySerializer\SerializedName(serializedName: "@type") - ] + #[JMS\VirtualProperty] + #[JMS\Groups(['nodes_sources', 'nodes_sources_default'])] + #[JMS\SerializedName('@type')] + #[Serializer\Groups(['nodes_sources', 'nodes_sources_default'])] + #[Serializer\SerializedName(serializedName: '@type')] public function getNodeTypeName(): string { return 'ArticleFeedBlock'; @@ -81,9 +71,9 @@ public function getNodeTypeName(): string /** * $this->nodeType->isReachable() proxy. - * * @return bool Does this nodeSource is reachable over network? */ + #[JMS\VirtualProperty] public function isReachable(): bool { return false; @@ -91,9 +81,9 @@ public function isReachable(): bool /** * $this->nodeType->isPublishable() proxy. - * * @return bool Does this nodeSource is publishable with date and time? */ + #[JMS\VirtualProperty] public function isPublishable(): bool { return false; diff --git a/src/GeneratedEntity/NSBasicBlock.php b/src/GeneratedEntity/NSBasicBlock.php index fc503940..af0e30c6 100644 --- a/src/GeneratedEntity/NSBasicBlock.php +++ b/src/GeneratedEntity/NSBasicBlock.php @@ -1,48 +1,67 @@ false])] + #[JMS\Groups(['nodes_sources', 'nodes_sources_default'])] + #[JMS\MaxDepth(2)] + #[JMS\Type('bool')] + private bool $booleanField = false; + /** - * Content. + * Image. + * (Virtual field, this var is a buffer) */ - #[ - SymfonySerializer\SerializedName(serializedName: "content"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_default"]), - \ApiPlatform\Metadata\ApiProperty(description: "Content"), - SymfonySerializer\MaxDepth(2), - Gedmo\Versioned, - ORM\Column(name: "content", type: "text", nullable: true), - Serializer\Groups(["nodes_sources", "nodes_sources_default"]), - Serializer\MaxDepth(2), - Serializer\Type("string") - ] - private ?string $content = null; + #[JMS\Exclude] + #[Serializer\SerializedName(serializedName: 'image')] + #[Serializer\Groups(['nodes_sources', 'nodes_sources_default', 'nodes_sources_documents'])] + #[ApiProperty(description: 'Image')] + #[Serializer\MaxDepth(2)] + private ?array $image = null; /** * @return string|null @@ -53,41 +72,16 @@ public function getContent(): ?string } /** - * @param string|null $content - * * @return $this */ public function setContent(?string $content): static { $this->content = null !== $content ? - (string) $content : - null; - + (string) $content : + null; return $this; } - - /** - * Boolean field. - */ - #[ - SymfonySerializer\SerializedName(serializedName: "booleanField"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_default"]), - \ApiPlatform\Metadata\ApiProperty(description: "Boolean field"), - SymfonySerializer\MaxDepth(2), - Gedmo\Versioned, - ORM\Column( - name: "boolean_field", - type: "boolean", - nullable: false, - options: ["default" => false] - ), - Serializer\Groups(["nodes_sources", "nodes_sources_default"]), - Serializer\MaxDepth(2), - Serializer\Type("bool") - ] - private bool $booleanField = false; - /** * @return bool */ @@ -97,42 +91,22 @@ public function getBooleanField(): bool } /** - * @param bool $booleanField - * * @return $this */ public function setBooleanField(bool $booleanField): static { $this->booleanField = $booleanField; - return $this; } - - /** - * Image. - * - * (Virtual field, this var is a buffer) - */ - #[ - Serializer\Exclude, - SymfonySerializer\SerializedName(serializedName: "image"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_default", "nodes_sources_documents"]), - \ApiPlatform\Metadata\ApiProperty(description: "Image"), - SymfonySerializer\MaxDepth(2) - ] - private ?array $image = null; - /** - * @return \RZ\Roadiz\CoreBundle\Entity\Document[] Documents array + * @return \RZ\Roadiz\CoreBundle\Entity\Document[] */ - #[ - Serializer\Groups(["nodes_sources", "nodes_sources_default", "nodes_sources_documents"]), - Serializer\MaxDepth(2), - Serializer\VirtualProperty, - Serializer\SerializedName("image"), - Serializer\Type("array") - ] + #[JMS\Groups(['nodes_sources', 'nodes_sources_default', 'nodes_sources_documents'])] + #[JMS\MaxDepth(2)] + #[JMS\VirtualProperty] + #[JMS\SerializedName('image')] + #[JMS\Type('array')] public function getImage(): array { if (null === $this->image) { @@ -151,35 +125,31 @@ public function getImage(): array } /** - * @param \RZ\Roadiz\CoreBundle\Entity\Document $document - * * @return $this */ public function addImage(\RZ\Roadiz\CoreBundle\Entity\Document $document): static { - if (null !== $this->objectManager) { - $nodeSourceDocument = new \RZ\Roadiz\CoreBundle\Entity\NodesSourcesDocuments( - $this, - $document - ); - $nodeSourceDocument->setFieldName('image'); - if (!$this->hasNodesSourcesDocuments($nodeSourceDocument)) { - $this->objectManager->persist($nodeSourceDocument); - $this->addDocumentsByFields($nodeSourceDocument); - $this->image = null; - } + if (null === $this->objectManager) { + return $this; + } + $nodeSourceDocument = new \RZ\Roadiz\CoreBundle\Entity\NodesSourcesDocuments( + $this, + $document + ); + $nodeSourceDocument->setFieldName('image'); + if (!$this->hasNodesSourcesDocuments($nodeSourceDocument)) { + $this->objectManager->persist($nodeSourceDocument); + $this->addDocumentsByFields($nodeSourceDocument); + $this->image = null; } return $this; } - - #[ - Serializer\VirtualProperty, - Serializer\Groups(["nodes_sources", "nodes_sources_default"]), - Serializer\SerializedName("@type"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_default"]), - SymfonySerializer\SerializedName(serializedName: "@type") - ] + #[JMS\VirtualProperty] + #[JMS\Groups(['nodes_sources', 'nodes_sources_default'])] + #[JMS\SerializedName('@type')] + #[Serializer\Groups(['nodes_sources', 'nodes_sources_default'])] + #[Serializer\SerializedName(serializedName: '@type')] public function getNodeTypeName(): string { return 'BasicBlock'; @@ -187,9 +157,9 @@ public function getNodeTypeName(): string /** * $this->nodeType->isReachable() proxy. - * * @return bool Does this nodeSource is reachable over network? */ + #[JMS\VirtualProperty] public function isReachable(): bool { return false; @@ -197,9 +167,9 @@ public function isReachable(): bool /** * $this->nodeType->isPublishable() proxy. - * * @return bool Does this nodeSource is publishable with date and time? */ + #[JMS\VirtualProperty] public function isPublishable(): bool { return false; diff --git a/src/GeneratedEntity/NSGroupBlock.php b/src/GeneratedEntity/NSGroupBlock.php index 44b869d1..e87bc446 100644 --- a/src/GeneratedEntity/NSGroupBlock.php +++ b/src/GeneratedEntity/NSGroupBlock.php @@ -1,40 +1,38 @@ nodeType->isReachable() proxy. - * * @return bool Does this nodeSource is reachable over network? */ + #[JMS\VirtualProperty] public function isReachable(): bool { return false; @@ -52,9 +50,9 @@ public function isReachable(): bool /** * $this->nodeType->isPublishable() proxy. - * * @return bool Does this nodeSource is publishable with date and time? */ + #[JMS\VirtualProperty] public function isPublishable(): bool { return false; diff --git a/src/GeneratedEntity/NSMenu.php b/src/GeneratedEntity/NSMenu.php index ab180371..b3e96bf5 100644 --- a/src/GeneratedEntity/NSMenu.php +++ b/src/GeneratedEntity/NSMenu.php @@ -1,40 +1,38 @@ nodeType->isReachable() proxy. - * * @return bool Does this nodeSource is reachable over network? */ + #[JMS\VirtualProperty] public function isReachable(): bool { return false; @@ -52,9 +50,9 @@ public function isReachable(): bool /** * $this->nodeType->isPublishable() proxy. - * * @return bool Does this nodeSource is publishable with date and time? */ + #[JMS\VirtualProperty] public function isPublishable(): bool { return false; diff --git a/src/GeneratedEntity/NSMenuLink.php b/src/GeneratedEntity/NSMenuLink.php index ac9c6da5..1ec89f90 100644 --- a/src/GeneratedEntity/NSMenuLink.php +++ b/src/GeneratedEntity/NSMenuLink.php @@ -1,53 +1,69 @@ linkExternalUrl = null !== $linkExternalUrl ? - (string) $linkExternalUrl : - null; - + (string) $linkExternalUrl : + null; return $this; } - /** - * linkInternalReferenceSources NodesSources direct field buffer. - * (Virtual field, this var is a buffer) - * - * Référence au nœud (Page ou Bloc de page). - * Default values: Page, Article, ArticleContainer, Offer - * @var \RZ\Roadiz\CoreBundle\Entity\NodesSources[]|null + * @return \RZ\Roadiz\CoreBundle\Entity\NodesSources[] */ - #[ - Serializer\Exclude, - SymfonySerializer\SerializedName(serializedName: "linkInternalReference"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_default", "nodes_sources_nodes"]), - \ApiPlatform\Metadata\ApiProperty(description: "Référence au nœud (Page ou Bloc de page)"), - SymfonySerializer\MaxDepth(2) - ] - private ?array $linkInternalReferenceSources = null; - - /** - * @return \RZ\Roadiz\CoreBundle\Entity\NodesSources[] linkInternalReference nodes-sources array - */ - #[ - Serializer\Groups(["nodes_sources", "nodes_sources_default", "nodes_sources_nodes"]), - Serializer\MaxDepth(2), - Serializer\VirtualProperty, - Serializer\SerializedName("linkInternalReference"), - Serializer\Type("array") - ] + #[JMS\Groups(['nodes_sources', 'nodes_sources_default', 'nodes_sources_nodes'])] + #[JMS\MaxDepth(2)] + #[JMS\VirtualProperty] + #[JMS\SerializedName('linkInternalReference')] + #[JMS\Type('array')] public function getLinkInternalReferenceSources(): array { if (null === $this->linkInternalReferenceSources) { @@ -118,41 +111,22 @@ public function getLinkInternalReferenceSources(): array /** * @param \RZ\Roadiz\CoreBundle\Entity\NodesSources[]|null $linkInternalReferenceSources - * * @return $this */ public function setLinkInternalReferenceSources(?array $linkInternalReferenceSources): static { $this->linkInternalReferenceSources = $linkInternalReferenceSources; - return $this; } - - /** - * Image. - * - * (Virtual field, this var is a buffer) - */ - #[ - Serializer\Exclude, - SymfonySerializer\SerializedName(serializedName: "image"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_default", "nodes_sources_documents"]), - \ApiPlatform\Metadata\ApiProperty(description: "Image"), - SymfonySerializer\MaxDepth(2) - ] - private ?array $image = null; - /** - * @return \RZ\Roadiz\CoreBundle\Entity\Document[] Documents array + * @return \RZ\Roadiz\CoreBundle\Entity\Document[] */ - #[ - Serializer\Groups(["nodes_sources", "nodes_sources_default", "nodes_sources_documents"]), - Serializer\MaxDepth(2), - Serializer\VirtualProperty, - Serializer\SerializedName("image"), - Serializer\Type("array") - ] + #[JMS\Groups(['nodes_sources', 'nodes_sources_default', 'nodes_sources_documents'])] + #[JMS\MaxDepth(2)] + #[JMS\VirtualProperty] + #[JMS\SerializedName('image')] + #[JMS\Type('array')] public function getImage(): array { if (null === $this->image) { @@ -171,35 +145,31 @@ public function getImage(): array } /** - * @param \RZ\Roadiz\CoreBundle\Entity\Document $document - * * @return $this */ public function addImage(\RZ\Roadiz\CoreBundle\Entity\Document $document): static { - if (null !== $this->objectManager) { - $nodeSourceDocument = new \RZ\Roadiz\CoreBundle\Entity\NodesSourcesDocuments( - $this, - $document - ); - $nodeSourceDocument->setFieldName('image'); - if (!$this->hasNodesSourcesDocuments($nodeSourceDocument)) { - $this->objectManager->persist($nodeSourceDocument); - $this->addDocumentsByFields($nodeSourceDocument); - $this->image = null; - } + if (null === $this->objectManager) { + return $this; + } + $nodeSourceDocument = new \RZ\Roadiz\CoreBundle\Entity\NodesSourcesDocuments( + $this, + $document + ); + $nodeSourceDocument->setFieldName('image'); + if (!$this->hasNodesSourcesDocuments($nodeSourceDocument)) { + $this->objectManager->persist($nodeSourceDocument); + $this->addDocumentsByFields($nodeSourceDocument); + $this->image = null; } return $this; } - - #[ - Serializer\VirtualProperty, - Serializer\Groups(["nodes_sources", "nodes_sources_default"]), - Serializer\SerializedName("@type"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_default"]), - SymfonySerializer\SerializedName(serializedName: "@type") - ] + #[JMS\VirtualProperty] + #[JMS\Groups(['nodes_sources', 'nodes_sources_default'])] + #[JMS\SerializedName('@type')] + #[Serializer\Groups(['nodes_sources', 'nodes_sources_default'])] + #[Serializer\SerializedName(serializedName: '@type')] public function getNodeTypeName(): string { return 'MenuLink'; @@ -207,9 +177,9 @@ public function getNodeTypeName(): string /** * $this->nodeType->isReachable() proxy. - * * @return bool Does this nodeSource is reachable over network? */ + #[JMS\VirtualProperty] public function isReachable(): bool { return false; @@ -217,9 +187,9 @@ public function isReachable(): bool /** * $this->nodeType->isPublishable() proxy. - * * @return bool Does this nodeSource is publishable with date and time? */ + #[JMS\VirtualProperty] public function isPublishable(): bool { return false; diff --git a/src/GeneratedEntity/NSNeutral.php b/src/GeneratedEntity/NSNeutral.php index 14d410d8..1b0ed92a 100644 --- a/src/GeneratedEntity/NSNeutral.php +++ b/src/GeneratedEntity/NSNeutral.php @@ -1,52 +1,48 @@ number = null !== $number ? - (int) $number : - null; - + (int) $number : + null; return $this; } - - #[ - Serializer\VirtualProperty, - Serializer\Groups(["nodes_sources", "nodes_sources_default"]), - Serializer\SerializedName("@type"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_default"]), - SymfonySerializer\SerializedName(serializedName: "@type") - ] + #[JMS\VirtualProperty] + #[JMS\Groups(['nodes_sources', 'nodes_sources_default'])] + #[JMS\SerializedName('@type')] + #[Serializer\Groups(['nodes_sources', 'nodes_sources_default'])] + #[Serializer\SerializedName(serializedName: '@type')] public function getNodeTypeName(): string { return 'Neutral'; @@ -86,9 +76,9 @@ public function getNodeTypeName(): string /** * $this->nodeType->isReachable() proxy. - * * @return bool Does this nodeSource is reachable over network? */ + #[JMS\VirtualProperty] public function isReachable(): bool { return false; @@ -96,9 +86,9 @@ public function isReachable(): bool /** * $this->nodeType->isPublishable() proxy. - * * @return bool Does this nodeSource is publishable with date and time? */ + #[JMS\VirtualProperty] public function isPublishable(): bool { return false; diff --git a/src/GeneratedEntity/NSOffer.php b/src/GeneratedEntity/NSOffer.php index 1b088fda..e393b515 100644 --- a/src/GeneratedEntity/NSOffer.php +++ b/src/GeneratedEntity/NSOffer.php @@ -1,55 +1,103 @@ 'string', 'enum' => ['dark'], 'example' => 'dark'])] + #[Serializer\MaxDepth(2)] + #[ApiFilter(\ApiPlatform\Doctrine\Orm\Filter\SearchFilter::class, strategy: 'exact')] + #[ApiFilter(\RZ\Roadiz\CoreBundle\Api\Filter\NotFilter::class)] + #[Gedmo\Versioned] + #[ORM\Column(name: 'layout', type: 'string', nullable: true, length: 11)] + #[JMS\Groups(['nodes_sources', 'nodes_sources_default'])] + #[JMS\MaxDepth(2)] + #[JMS\Type('string')] + private ?string $layout = null; + /** * @return int|float|null */ @@ -59,42 +107,16 @@ public function getPrice(): int|float|null } /** - * @param int|float|null $price - * * @return $this */ public function setPrice(int|float|null $price): static { $this->price = null !== $price ? - (int) $price : - null; - + (int) $price : + null; return $this; } - - /** - * VAT. - */ - #[ - SymfonySerializer\SerializedName(serializedName: "vat"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_default"]), - \ApiPlatform\Metadata\ApiProperty(description: "VAT"), - SymfonySerializer\MaxDepth(2), - Gedmo\Versioned, - ORM\Column( - name: "vat", - type: "decimal", - nullable: true, - precision: 18, - scale: 3 - ), - Serializer\Groups(["nodes_sources", "nodes_sources_default"]), - Serializer\MaxDepth(2), - Serializer\Type("double") - ] - private int|float|null $vat = null; - /** * @return int|float|null */ @@ -104,114 +126,48 @@ public function getVat(): int|float|null } /** - * @param int|float|null $vat - * * @return $this */ public function setVat(int|float|null $vat): static { $this->vat = $vat; - return $this; } - - /** - * Geolocation. - */ - #[ - SymfonySerializer\SerializedName(serializedName: "geolocation"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_default"]), - \ApiPlatform\Metadata\ApiProperty(description: "Geolocation"), - SymfonySerializer\MaxDepth(2), - Gedmo\Versioned, - ORM\Column(name: "geolocation", type: "json", nullable: true), - Serializer\Groups(["nodes_sources", "nodes_sources_default"]), - Serializer\MaxDepth(2) - ] - private $geolocation = null; - /** * @return mixed */ - public function getGeolocation() + public function getGeolocation(): mixed { return $this->geolocation; } /** - * @param mixed $geolocation - * * @return $this */ - public function setGeolocation($geolocation): static + public function setGeolocation(mixed $geolocation): static { $this->geolocation = $geolocation; - return $this; } - - /** - * Multi geolocations. - */ - #[ - SymfonySerializer\SerializedName(serializedName: "multiGeolocation"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_default"]), - \ApiPlatform\Metadata\ApiProperty(description: "Multi geolocations"), - SymfonySerializer\MaxDepth(2), - Gedmo\Versioned, - ORM\Column(name: "multi_geolocation", type: "json", nullable: true), - Serializer\Groups(["nodes_sources", "nodes_sources_default"]), - Serializer\MaxDepth(2) - ] - private $multiGeolocation = null; - /** * @return mixed */ - public function getMultiGeolocation() + public function getMultiGeolocation(): mixed { return $this->multiGeolocation; } /** - * @param mixed $multiGeolocation - * * @return $this */ - public function setMultiGeolocation($multiGeolocation): static + public function setMultiGeolocation(mixed $multiGeolocation): static { $this->multiGeolocation = $multiGeolocation; - return $this; } - - /** - * Layout. - * Default values: dark - */ - #[ - SymfonySerializer\SerializedName(serializedName: "layout"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_default"]), - \ApiPlatform\Metadata\ApiProperty(description: "Layout", schema: ["type" => "string", "enum" => ["dark"], "example" => "dark"], example: "light"), - SymfonySerializer\MaxDepth(2), - ApiFilter(OrmFilter\SearchFilter::class, strategy: "exact"), - ApiFilter(\RZ\Roadiz\CoreBundle\Api\Filter\NotFilter::class), - Gedmo\Versioned, - ORM\Column( - name: "layout", - type: "string", - nullable: true, - length: 11 - ), - Serializer\Groups(["nodes_sources", "nodes_sources_default"]), - Serializer\MaxDepth(2), - Serializer\Type("string") - ] - private ?string $layout = null; - /** * @return string|null */ @@ -221,27 +177,21 @@ public function getLayout(): ?string } /** - * @param string|null $layout - * * @return $this */ public function setLayout(?string $layout): static { $this->layout = null !== $layout ? - (string) $layout : - null; - + (string) $layout : + null; return $this; } - - #[ - Serializer\VirtualProperty, - Serializer\Groups(["nodes_sources", "nodes_sources_default"]), - Serializer\SerializedName("@type"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_default"]), - SymfonySerializer\SerializedName(serializedName: "@type") - ] + #[JMS\VirtualProperty] + #[JMS\Groups(['nodes_sources', 'nodes_sources_default'])] + #[JMS\SerializedName('@type')] + #[Serializer\Groups(['nodes_sources', 'nodes_sources_default'])] + #[Serializer\SerializedName(serializedName: '@type')] public function getNodeTypeName(): string { return 'Offer'; @@ -249,9 +199,9 @@ public function getNodeTypeName(): string /** * $this->nodeType->isReachable() proxy. - * * @return bool Does this nodeSource is reachable over network? */ + #[JMS\VirtualProperty] public function isReachable(): bool { return true; @@ -259,9 +209,9 @@ public function isReachable(): bool /** * $this->nodeType->isPublishable() proxy. - * * @return bool Does this nodeSource is publishable with date and time? */ + #[JMS\VirtualProperty] public function isPublishable(): bool { return false; diff --git a/src/GeneratedEntity/NSPage.php b/src/GeneratedEntity/NSPage.php index 4da3ba62..7a5175a6 100644 --- a/src/GeneratedEntity/NSPage.php +++ b/src/GeneratedEntity/NSPage.php @@ -1,54 +1,383 @@ false])] + #[JMS\Groups(['nodes_sources', 'nodes_sources_boolean'])] + #[JMS\MaxDepth(2)] + #[JMS\Type('bool')] + private bool $sticky = false; + + /** + * Sticky test. + * Group: Boolean. + */ + #[Serializer\SerializedName(serializedName: 'stickytest')] + #[Serializer\Groups(['nodes_sources', 'nodes_sources_boolean'])] + #[ApiProperty(description: 'Sticky test')] + #[Serializer\MaxDepth(2)] + #[ApiFilter(\ApiPlatform\Doctrine\Orm\Filter\OrderFilter::class)] + #[ApiFilter(\ApiPlatform\Doctrine\Orm\Filter\BooleanFilter::class)] + #[Gedmo\Versioned] + #[ORM\Column(name: 'stickytest', type: 'boolean', nullable: false, options: ['default' => false])] + #[JMS\Groups(['nodes_sources', 'nodes_sources_boolean'])] + #[JMS\MaxDepth(2)] + #[JMS\Type('bool')] + private bool $stickytest = false; + + /** + * Custom form. + * (Virtual field, this var is a buffer) + */ + #[JMS\Exclude] + #[Serializer\SerializedName(serializedName: 'customForm')] + #[Serializer\Groups(['nodes_sources', 'nodes_sources_default', 'nodes_sources_custom_forms'])] + #[ApiProperty(description: 'Custom form')] + #[Serializer\MaxDepth(2)] + private ?array $customForm = null; + + /** + * Buffer var to get referenced entities (documents, nodes, cforms, doctrine entities) + * Reference to users. + * @var \Doctrine\Common\Collections\Collection + */ + #[JMS\Exclude] + #[Serializer\Ignore] + #[ORM\OneToMany( + targetEntity: \App\Entity\PositionedPageUser::class, + mappedBy: 'nodeSource', + orphanRemoval: true, + cascade: ['persist', 'remove'], + )] + #[ORM\OrderBy(['position' => 'ASC'])] + private Collection $usersProxy; + + /** + * Reference to folders. + * Default values: + * # Entity class name + * classname: RZ\Roadiz\CoreBundle\Entity\Folder + * # Displayable is the method used to display entity name + * displayable: getName + * # Same as Displayable but for a secondary information + * alt_displayable: getFullPath + * # Searchable entity fields + * searchable: + * - folderName + * orderBy: + * - field: position + * direction: ASC + * # Use a proxy entity + * # proxy: + * # classname: App\Entity\PositionedFolderGalleryBlock + * # self: nodeSource + * # relation: folder + * # # This order will preserve position + * # orderBy: + * # - field: position + * # direction: ASC + * @var \Doctrine\Common\Collections\Collection + */ + #[Serializer\SerializedName(serializedName: 'folderReferences')] + #[Serializer\Groups(['nodes_sources', 'nodes_sources_default'])] + #[ApiProperty(description: 'Reference to folders')] + #[Serializer\MaxDepth(2)] + #[ORM\ManyToMany(targetEntity: \RZ\Roadiz\CoreBundle\Entity\Folder::class)] + #[ORM\JoinTable(name: 'page_folder_references')] + #[ORM\JoinColumn(name: 'page_id', referencedColumnName: 'id', onDelete: 'CASCADE')] + #[ORM\InverseJoinColumn(name: 'folder_references_id', referencedColumnName: 'id', onDelete: 'CASCADE')] + #[ORM\OrderBy(['position' => 'ASC'])] + #[ApiFilter(\ApiPlatform\Doctrine\Orm\Filter\SearchFilter::class, strategy: 'exact')] + #[JMS\Groups(['nodes_sources', 'nodes_sources_default'])] + #[JMS\MaxDepth(2)] + private Collection $folderReferences; + + /** Amount. */ + #[Serializer\SerializedName(serializedName: 'amount')] + #[Serializer\Groups(['nodes_sources', 'nodes_sources_default'])] + #[ApiProperty(description: 'Amount')] + #[Serializer\MaxDepth(2)] + #[Gedmo\Versioned] + #[ORM\Column(name: 'amount', type: 'decimal', nullable: true, precision: 18, scale: 3)] + #[JMS\Groups(['nodes_sources', 'nodes_sources_default'])] + #[JMS\MaxDepth(2)] + #[JMS\Type('double')] + private int|float|null $amount = null; + + /** Test email. */ + #[Serializer\SerializedName(serializedName: 'emailTest')] + #[Serializer\Groups(['nodes_sources', 'nodes_sources_default'])] + #[ApiProperty(description: 'Test email')] + #[Serializer\MaxDepth(2)] + #[Gedmo\Versioned] + #[ORM\Column(name: 'email_test', type: 'string', nullable: true, length: 250)] + #[JMS\Groups(['nodes_sources', 'nodes_sources_default'])] + #[JMS\MaxDepth(2)] + #[JMS\Type('string')] + private ?string $emailTest = null; + + /** + * Settings. + * Default values: + * classname: Themes\Rozier\Explorer\SettingsProvider + */ + #[Serializer\SerializedName(serializedName: 'settings')] + #[Serializer\Groups(['nodes_sources', 'nodes_sources_default'])] + #[ApiProperty(description: 'Settings')] + #[Serializer\MaxDepth(2)] + #[Gedmo\Versioned] + #[ORM\Column(name: 'settings', type: 'json', nullable: true)] + #[JMS\Groups(['nodes_sources', 'nodes_sources_default'])] + #[JMS\MaxDepth(2)] + private mixed $settings = null; + + /** + * Folder simple. + * Default values: + * classname: Themes\Rozier\Explorer\FoldersProvider + */ + #[Serializer\SerializedName(serializedName: 'folder')] + #[Serializer\Groups(['nodes_sources', 'nodes_sources_default'])] + #[ApiProperty(description: 'Folder simple')] + #[Serializer\MaxDepth(2)] + #[Gedmo\Versioned] + #[ORM\Column(name: 'folder', type: 'string', nullable: true, length: 250)] + #[JMS\Groups(['nodes_sources', 'nodes_sources_default'])] + #[JMS\MaxDepth(2)] + private mixed $folder = null; + + /** Country. */ + #[Serializer\SerializedName(serializedName: 'country')] + #[Serializer\Groups(['nodes_sources', 'nodes_sources_default'])] + #[ApiProperty(description: 'Country')] + #[Serializer\MaxDepth(2)] + #[Gedmo\Versioned] + #[ORM\Column(name: 'country', type: 'string', nullable: true, length: 5)] + #[JMS\Groups(['nodes_sources', 'nodes_sources_default'])] + #[JMS\MaxDepth(2)] + #[JMS\Type('string')] + private ?string $country = null; + + /** Geolocation. */ + #[Serializer\SerializedName(serializedName: 'geolocation')] + #[Serializer\Groups(['nodes_sources', 'nodes_sources_default'])] + #[ApiProperty(description: 'Geolocation')] + #[Serializer\MaxDepth(2)] + #[Gedmo\Versioned] + #[ORM\Column(name: 'geolocation', type: 'json', nullable: true)] + #[JMS\Groups(['nodes_sources', 'nodes_sources_default'])] + #[JMS\MaxDepth(2)] + private mixed $geolocation = null; + + /** + * Multi geolocations. + * Group: Geo. + */ + #[Serializer\SerializedName(serializedName: 'multiGeolocation')] + #[Serializer\Groups(['nodes_sources', 'nodes_sources_geo'])] + #[ApiProperty(description: 'Multi geolocations')] + #[Serializer\MaxDepth(2)] + #[Gedmo\Versioned] + #[ORM\Column(name: 'multi_geolocation', type: 'json', nullable: true)] + #[JMS\Groups(['nodes_sources', 'nodes_sources_geo'])] + #[JMS\MaxDepth(2)] + private mixed $multiGeolocation = null; + + /** + * Layout. + * Default values: + * dark, transparent + */ + #[Serializer\SerializedName(serializedName: 'layout')] + #[Serializer\Groups(['nodes_sources', 'nodes_sources_default'])] + #[ApiProperty( + description: 'Layout', + example: 'light', + schema: ['type' => 'string', 'enum' => ['dark', 'transparent'], 'example' => 'dark'], + )] + #[Serializer\MaxDepth(2)] + #[ApiFilter(\ApiPlatform\Doctrine\Orm\Filter\SearchFilter::class, strategy: 'exact')] + #[ApiFilter(\RZ\Roadiz\CoreBundle\Api\Filter\NotFilter::class)] + #[Gedmo\Versioned] + #[ORM\Column(name: 'layout', type: 'string', nullable: true, length: 11)] + #[JMS\Groups(['nodes_sources', 'nodes_sources_default'])] + #[JMS\MaxDepth(2)] + #[JMS\Type('string')] + private ?string $layout = null; + + /** + * Main user. + * Default values: + * # Entity class name + * classname: \RZ\Roadiz\CoreBundle\Entity\User + * # Displayable is the method used to display entity name + * displayable: getUsername + * # Same as Displayable but for a secondary information + * alt_displayable: getEmail + * # Same as Displayable but for a secondary information + * thumbnail: ~ + * # Searchable entity fields + * searchable: + * - username + * - email + * # This order will only be used for explorer + * orderBy: + * - field: email + * direction: ASC + */ + #[Serializer\SerializedName(serializedName: 'mainUser')] + #[Serializer\Groups(['nodes_sources', 'nodes_sources_default'])] + #[ApiProperty(description: 'Main user')] + #[Serializer\MaxDepth(2)] + #[ORM\ManyToOne(targetEntity: \RZ\Roadiz\CoreBundle\Entity\User::class)] + #[ORM\JoinColumn(name: 'main_user_id', referencedColumnName: 'id', onDelete: 'SET NULL')] + #[ApiFilter(\ApiPlatform\Doctrine\Orm\Filter\SearchFilter::class, strategy: 'exact')] + #[JMS\Groups(['nodes_sources', 'nodes_sources_default'])] + #[JMS\MaxDepth(2)] + private ?\RZ\Roadiz\CoreBundle\Entity\User $mainUser = null; + /** * @return string|null */ @@ -58,41 +387,16 @@ public function getContent(): ?string } /** - * @param string|null $content - * * @return $this */ public function setContent(?string $content): static { $this->content = null !== $content ? - (string) $content : - null; - + (string) $content : + null; return $this; } - - /** - * Sub-title. - */ - #[ - SymfonySerializer\SerializedName(serializedName: "subTitle"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_default"]), - \ApiPlatform\Metadata\ApiProperty(description: "Sub-title"), - SymfonySerializer\MaxDepth(2), - Gedmo\Versioned, - ORM\Column( - name: "sub_title", - type: "string", - nullable: true, - length: 250 - ), - Serializer\Groups(["nodes_sources", "nodes_sources_default"]), - Serializer\MaxDepth(2), - Serializer\Type("string") - ] - private ?string $subTitle = null; - /** * @return string|null */ @@ -102,41 +406,16 @@ public function getSubTitle(): ?string } /** - * @param string|null $subTitle - * * @return $this */ public function setSubTitle(?string $subTitle): static { $this->subTitle = null !== $subTitle ? - (string) $subTitle : - null; - + (string) $subTitle : + null; return $this; } - - /** - * Page color. - */ - #[ - SymfonySerializer\SerializedName(serializedName: "color"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_default"]), - \ApiPlatform\Metadata\ApiProperty(description: "Page color"), - SymfonySerializer\MaxDepth(2), - Gedmo\Versioned, - ORM\Column( - name: "color", - type: "string", - nullable: true, - length: 10 - ), - Serializer\Groups(["nodes_sources", "nodes_sources_default"]), - Serializer\MaxDepth(2), - Serializer\Type("string") - ] - private ?string $color = null; - /** * @return string|null */ @@ -146,44 +425,24 @@ public function getColor(): ?string } /** - * @param string|null $color - * * @return $this */ public function setColor(?string $color): static { $this->color = null !== $color ? - (string) $color : - null; - + (string) $color : + null; return $this; } - /** - * Images. - * - * (Virtual field, this var is a buffer) + * @return \RZ\Roadiz\CoreBundle\Entity\Document[] */ - #[ - Serializer\Exclude, - SymfonySerializer\SerializedName(serializedName: "images"), - SymfonySerializer\Groups(["realm_a"]), - \ApiPlatform\Metadata\ApiProperty(description: "Images"), - SymfonySerializer\MaxDepth(2) - ] - private ?array $images = null; - - /** - * @return \RZ\Roadiz\CoreBundle\Entity\Document[] Documents array - */ - #[ - Serializer\Groups(["realm_a"]), - Serializer\MaxDepth(2), - Serializer\VirtualProperty, - Serializer\SerializedName("images"), - Serializer\Type("array") - ] + #[JMS\Groups(['realm_a'])] + #[JMS\MaxDepth(2)] + #[JMS\VirtualProperty] + #[JMS\SerializedName('images')] + #[JMS\Type('array')] public function getImages(): array { if (null === $this->images) { @@ -202,53 +461,34 @@ public function getImages(): array } /** - * @param \RZ\Roadiz\CoreBundle\Entity\Document $document - * * @return $this */ public function addImages(\RZ\Roadiz\CoreBundle\Entity\Document $document): static { - if (null !== $this->objectManager) { - $nodeSourceDocument = new \RZ\Roadiz\CoreBundle\Entity\NodesSourcesDocuments( - $this, - $document - ); - $nodeSourceDocument->setFieldName('images'); - if (!$this->hasNodesSourcesDocuments($nodeSourceDocument)) { - $this->objectManager->persist($nodeSourceDocument); - $this->addDocumentsByFields($nodeSourceDocument); - $this->images = null; - } + if (null === $this->objectManager) { + return $this; + } + $nodeSourceDocument = new \RZ\Roadiz\CoreBundle\Entity\NodesSourcesDocuments( + $this, + $document + ); + $nodeSourceDocument->setFieldName('images'); + if (!$this->hasNodesSourcesDocuments($nodeSourceDocument)) { + $this->objectManager->persist($nodeSourceDocument); + $this->addDocumentsByFields($nodeSourceDocument); + $this->images = null; } return $this; } - - /** - * Header image. - * Group: Images. - * - * (Virtual field, this var is a buffer) - */ - #[ - Serializer\Exclude, - SymfonySerializer\SerializedName(serializedName: "headerImage"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_images", "nodes_sources_documents"]), - \ApiPlatform\Metadata\ApiProperty(description: "Header image"), - SymfonySerializer\MaxDepth(2) - ] - private ?array $headerImage = null; - /** - * @return \RZ\Roadiz\CoreBundle\Entity\Document[] Documents array + * @return \RZ\Roadiz\CoreBundle\Entity\Document[] */ - #[ - Serializer\Groups(["nodes_sources", "nodes_sources_images", "nodes_sources_documents"]), - Serializer\MaxDepth(2), - Serializer\VirtualProperty, - Serializer\SerializedName("headerImage"), - Serializer\Type("array") - ] + #[JMS\Groups(['nodes_sources', 'nodes_sources_images', 'nodes_sources_documents'])] + #[JMS\MaxDepth(2)] + #[JMS\VirtualProperty] + #[JMS\SerializedName('headerImage')] + #[JMS\Type('array')] public function getHeaderImage(): array { if (null === $this->headerImage) { @@ -267,49 +507,26 @@ public function getHeaderImage(): array } /** - * @param \RZ\Roadiz\CoreBundle\Entity\Document $document - * * @return $this */ public function addHeaderImage(\RZ\Roadiz\CoreBundle\Entity\Document $document): static { - if (null !== $this->objectManager) { - $nodeSourceDocument = new \RZ\Roadiz\CoreBundle\Entity\NodesSourcesDocuments( - $this, - $document - ); - $nodeSourceDocument->setFieldName('header_image'); - if (!$this->hasNodesSourcesDocuments($nodeSourceDocument)) { - $this->objectManager->persist($nodeSourceDocument); - $this->addDocumentsByFields($nodeSourceDocument); - $this->headerImage = null; - } + if (null === $this->objectManager) { + return $this; + } + $nodeSourceDocument = new \RZ\Roadiz\CoreBundle\Entity\NodesSourcesDocuments( + $this, + $document + ); + $nodeSourceDocument->setFieldName('header_image'); + if (!$this->hasNodesSourcesDocuments($nodeSourceDocument)) { + $this->objectManager->persist($nodeSourceDocument); + $this->addDocumentsByFields($nodeSourceDocument); + $this->headerImage = null; } return $this; } - - /** - * Overtitle. - */ - #[ - SymfonySerializer\SerializedName(serializedName: "overTitle"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_default"]), - \ApiPlatform\Metadata\ApiProperty(description: "Overtitle"), - SymfonySerializer\MaxDepth(2), - Gedmo\Versioned, - ORM\Column( - name: "over_title", - type: "string", - nullable: true, - length: 250 - ), - Serializer\Groups(["nodes_sources", "nodes_sources_default"]), - Serializer\MaxDepth(2), - Serializer\Type("string") - ] - private ?string $overTitle = null; - /** * @return string|null */ @@ -319,46 +536,24 @@ public function getOverTitle(): ?string } /** - * @param string|null $overTitle - * * @return $this */ public function setOverTitle(?string $overTitle): static { $this->overTitle = null !== $overTitle ? - (string) $overTitle : - null; - + (string) $overTitle : + null; return $this; } - /** - * Pictures. - * Picture for website. - * Group: Images. - * - * (Virtual field, this var is a buffer) + * @return \RZ\Roadiz\CoreBundle\Entity\Document[] */ - #[ - Serializer\Exclude, - SymfonySerializer\SerializedName(serializedName: "pictures"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_images", "nodes_sources_documents"]), - \ApiPlatform\Metadata\ApiProperty(description: "Pictures: Picture for website"), - SymfonySerializer\MaxDepth(2) - ] - private ?array $pictures = null; - - /** - * @return \RZ\Roadiz\CoreBundle\Entity\Document[] Documents array - */ - #[ - Serializer\Groups(["nodes_sources", "nodes_sources_images", "nodes_sources_documents"]), - Serializer\MaxDepth(2), - Serializer\VirtualProperty, - Serializer\SerializedName("pictures"), - Serializer\Type("array") - ] + #[JMS\Groups(['nodes_sources', 'nodes_sources_images', 'nodes_sources_documents'])] + #[JMS\MaxDepth(2)] + #[JMS\VirtualProperty] + #[JMS\SerializedName('pictures')] + #[JMS\Type('array')] public function getPictures(): array { if (null === $this->pictures) { @@ -377,55 +572,34 @@ public function getPictures(): array } /** - * @param \RZ\Roadiz\CoreBundle\Entity\Document $document - * * @return $this */ public function addPictures(\RZ\Roadiz\CoreBundle\Entity\Document $document): static { - if (null !== $this->objectManager) { - $nodeSourceDocument = new \RZ\Roadiz\CoreBundle\Entity\NodesSourcesDocuments( - $this, - $document - ); - $nodeSourceDocument->setFieldName('pictures'); - if (!$this->hasNodesSourcesDocuments($nodeSourceDocument)) { - $this->objectManager->persist($nodeSourceDocument); - $this->addDocumentsByFields($nodeSourceDocument); - $this->pictures = null; - } + if (null === $this->objectManager) { + return $this; + } + $nodeSourceDocument = new \RZ\Roadiz\CoreBundle\Entity\NodesSourcesDocuments( + $this, + $document + ); + $nodeSourceDocument->setFieldName('pictures'); + if (!$this->hasNodesSourcesDocuments($nodeSourceDocument)) { + $this->objectManager->persist($nodeSourceDocument); + $this->addDocumentsByFields($nodeSourceDocument); + $this->pictures = null; } return $this; } - - /** - * nodeReferencesSources NodesSources direct field buffer. - * (Virtual field, this var is a buffer) - * - * References. - * Default values: Page - * @var \App\GeneratedEntity\NSPage[]|null - */ - #[ - Serializer\Exclude, - SymfonySerializer\SerializedName(serializedName: "nodeReferences"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_default", "nodes_sources_nodes"]), - \ApiPlatform\Metadata\ApiProperty(description: "References"), - SymfonySerializer\MaxDepth(2) - ] - private ?array $nodeReferencesSources = null; - /** - * @return \App\GeneratedEntity\NSPage[] nodeReferences nodes-sources array + * @return \App\GeneratedEntity\NSPage[] */ - #[ - Serializer\Groups(["nodes_sources", "nodes_sources_default", "nodes_sources_nodes"]), - Serializer\MaxDepth(2), - Serializer\VirtualProperty, - Serializer\SerializedName("nodeReferences"), - Serializer\Type("array") - ] + #[JMS\Groups(['nodes_sources', 'nodes_sources_default', 'nodes_sources_nodes'])] + #[JMS\MaxDepth(2)] + #[JMS\VirtualProperty] + #[JMS\SerializedName('nodeReferences')] + #[JMS\Type('array')] public function getNodeReferencesSources(): array { if (null === $this->nodeReferencesSources) { @@ -445,41 +619,14 @@ public function getNodeReferencesSources(): array /** * @param \App\GeneratedEntity\NSPage[]|null $nodeReferencesSources - * * @return $this */ public function setNodeReferencesSources(?array $nodeReferencesSources): static { $this->nodeReferencesSources = $nodeReferencesSources; - return $this; } - - /** - * Sticky. - * Group: Boolean. - */ - #[ - SymfonySerializer\SerializedName(serializedName: "sticky"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_boolean"]), - \ApiPlatform\Metadata\ApiProperty(description: "Sticky"), - SymfonySerializer\MaxDepth(2), - ApiFilter(OrmFilter\OrderFilter::class), - ApiFilter(OrmFilter\BooleanFilter::class), - Gedmo\Versioned, - ORM\Column( - name: "sticky", - type: "boolean", - nullable: false, - options: ["default" => false] - ), - Serializer\Groups(["nodes_sources", "nodes_sources_boolean"]), - Serializer\MaxDepth(2), - Serializer\Type("bool") - ] - private bool $sticky = false; - /** * @return bool */ @@ -489,42 +636,14 @@ public function getSticky(): bool } /** - * @param bool $sticky - * * @return $this */ public function setSticky(bool $sticky): static { $this->sticky = $sticky; - return $this; } - - /** - * Sticky test. - * Group: Boolean. - */ - #[ - SymfonySerializer\SerializedName(serializedName: "stickytest"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_boolean"]), - \ApiPlatform\Metadata\ApiProperty(description: "Sticky test"), - SymfonySerializer\MaxDepth(2), - ApiFilter(OrmFilter\OrderFilter::class), - ApiFilter(OrmFilter\BooleanFilter::class), - Gedmo\Versioned, - ORM\Column( - name: "stickytest", - type: "boolean", - nullable: false, - options: ["default" => false] - ), - Serializer\Groups(["nodes_sources", "nodes_sources_boolean"]), - Serializer\MaxDepth(2), - Serializer\Type("bool") - ] - private bool $stickytest = false; - /** * @return bool */ @@ -534,41 +653,21 @@ public function getStickytest(): bool } /** - * @param bool $stickytest - * * @return $this */ public function setStickytest(bool $stickytest): static { $this->stickytest = $stickytest; - return $this; } - - /** - * Custom form. - * - * (Virtual field, this var is a buffer) - */ - #[ - Serializer\Exclude, - SymfonySerializer\SerializedName(serializedName: "customForm"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_default", "nodes_sources_custom_forms"]), - \ApiPlatform\Metadata\ApiProperty(description: "Custom form"), - SymfonySerializer\MaxDepth(2) - ] - private ?array $customForm = null; - /** * @return \RZ\Roadiz\CoreBundle\Entity\CustomForm[] CustomForm array */ - #[ - Serializer\Groups(["nodes_sources", "nodes_sources_default", "nodes_sources_custom_forms"]), - Serializer\MaxDepth(2), - Serializer\VirtualProperty, - Serializer\SerializedName("customForm") - ] + #[JMS\Groups(['nodes_sources', 'nodes_sources_default', 'nodes_sources_custom_forms'])] + #[JMS\MaxDepth(2)] + #[JMS\VirtualProperty] + #[JMS\SerializedName('customForm')] public function getCustomForm(): array { if (null === $this->customForm) { @@ -587,8 +686,6 @@ public function getCustomForm(): array } /** - * @param \RZ\Roadiz\CoreBundle\Entity\CustomForm $customForm - * * @return $this */ public function addCustomForm(\RZ\Roadiz\CoreBundle\Entity\CustomForm $customForm): static @@ -606,68 +703,42 @@ public function addCustomForm(\RZ\Roadiz\CoreBundle\Entity\CustomForm $customFor return $this; } - /** - * Reference to users - * - * @var Collection - */ - #[ - Serializer\Exclude, - SymfonySerializer\Ignore, - ORM\OneToMany( - targetEntity: \App\Entity\PositionedPageUser::class, - mappedBy: "nodeSource", - orphanRemoval: true, - cascade: ["persist", "remove"] - ), - ORM\OrderBy(["position" => "ASC"]) - ] - private Collection $usersProxy; - - /** - * @return Collection + * @return \Doctrine\Common\Collections\Collection */ public function getUsersProxy(): Collection { return $this->usersProxy; } - /** - * @return Collection - */ - #[ - Serializer\Groups(["nodes_sources", "nodes_sources_default"]), - Serializer\MaxDepth(2), - Serializer\VirtualProperty, - Serializer\SerializedName("users"), - SymfonySerializer\SerializedName(serializedName: "users"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_default"]), - SymfonySerializer\MaxDepth(2) - ] - public function getUsers(): Collection + #[JMS\Groups(['nodes_sources', 'nodes_sources_default'])] + #[JMS\MaxDepth(2)] + #[JMS\VirtualProperty] + #[JMS\SerializedName('users')] + #[Serializer\SerializedName(serializedName: 'users')] + #[Serializer\Groups(['nodes_sources', 'nodes_sources_default'])] + #[Serializer\MaxDepth(2)] + public function getUsers(): array { return $this->usersProxy->map(function (\App\Entity\PositionedPageUser $proxyEntity) { return $proxyEntity->getUser(); - }); + })->getValues(); } /** - * @param Collection $usersProxy - * @Serializer\VirtualProperty() + * @param \Doctrine\Common\Collections\Collection $usersProxy * @return $this */ public function setUsersProxy(Collection $usersProxy): static { $this->usersProxy = $usersProxy; - return $this; } + /** - * @param Collection|array|null $users * @return $this */ - public function setUsers(Collection|array|null $users = null): static + public function setUsers(Collection|array|null $users): static { foreach ($this->getUsersProxy() as $item) { $item->setNodeSource(null); @@ -690,50 +761,8 @@ public function setUsers(Collection|array|null $users = null): static return $this; } - - /** - * Reference to folders. - * Default values: # Entity class name - * classname: RZ\Roadiz\CoreBundle\Entity\Folder - * # Displayable is the method used to display entity name - * displayable: getName - * # Same as Displayable but for a secondary information - * alt_displayable: getFullPath - * # Searchable entity fields - * searchable: - * - folderName - * orderBy: - * - field: position - * direction: ASC - * # Use a proxy entity - * # proxy: - * # classname: App\Entity\PositionedFolderGalleryBlock - * # self: nodeSource - * # relation: folder - * # # This order will preserve position - * # orderBy: - * # - field: position - * # direction: ASC - * @var Collection - */ - #[ - SymfonySerializer\SerializedName(serializedName: "folderReferences"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_default"]), - \ApiPlatform\Metadata\ApiProperty(description: "Reference to folders"), - SymfonySerializer\MaxDepth(2), - ORM\ManyToMany(targetEntity: \RZ\Roadiz\CoreBundle\Entity\Folder::class), - ORM\JoinTable(name: "page_folder_references"), - ORM\JoinColumn(name: "page_id", referencedColumnName: "id", onDelete: "CASCADE"), - ORM\InverseJoinColumn(name: "folder_references_id", referencedColumnName: "id", onDelete: "CASCADE"), - ORM\OrderBy(["position" => "ASC"]), - ApiFilter(OrmFilter\SearchFilter::class, strategy: "exact"), - Serializer\Groups(["nodes_sources", "nodes_sources_default"]), - Serializer\MaxDepth(2) - ] - private Collection $folderReferences; - /** - * @return Collection + * @return \Doctrine\Common\Collections\Collection */ public function getFolderReferences(): Collection { @@ -741,7 +770,7 @@ public function getFolderReferences(): Collection } /** - * @param Collection|\RZ\Roadiz\CoreBundle\Entity\Folder[] $folderReferences + * @param \Doctrine\Common\Collections\Collection|array<\RZ\Roadiz\CoreBundle\Entity\Folder> $folderReferences * @return $this */ public function setFolderReferences(Collection|array $folderReferences): static @@ -751,33 +780,9 @@ public function setFolderReferences(Collection|array $folderReferences): static } else { $this->folderReferences = new \Doctrine\Common\Collections\ArrayCollection($folderReferences); } - return $this; } - - /** - * Amount. - */ - #[ - SymfonySerializer\SerializedName(serializedName: "amount"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_default"]), - \ApiPlatform\Metadata\ApiProperty(description: "Amount"), - SymfonySerializer\MaxDepth(2), - Gedmo\Versioned, - ORM\Column( - name: "amount", - type: "decimal", - nullable: true, - precision: 18, - scale: 3 - ), - Serializer\Groups(["nodes_sources", "nodes_sources_default"]), - Serializer\MaxDepth(2), - Serializer\Type("double") - ] - private int|float|null $amount = null; - /** * @return int|float|null */ @@ -787,39 +792,14 @@ public function getAmount(): int|float|null } /** - * @param int|float|null $amount - * * @return $this */ public function setAmount(int|float|null $amount): static { $this->amount = $amount; - return $this; } - - /** - * Test email. - */ - #[ - SymfonySerializer\SerializedName(serializedName: "emailTest"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_default"]), - \ApiPlatform\Metadata\ApiProperty(description: "Test email"), - SymfonySerializer\MaxDepth(2), - Gedmo\Versioned, - ORM\Column( - name: "email_test", - type: "string", - nullable: true, - length: 250 - ), - Serializer\Groups(["nodes_sources", "nodes_sources_default"]), - Serializer\MaxDepth(2), - Serializer\Type("string") - ] - private ?string $emailTest = null; - /** * @return string|null */ @@ -829,120 +809,50 @@ public function getEmailTest(): ?string } /** - * @param string|null $emailTest - * * @return $this */ public function setEmailTest(?string $emailTest): static { $this->emailTest = null !== $emailTest ? - (string) $emailTest : - null; - + (string) $emailTest : + null; return $this; } - - /** - * Settings. - * Default values: classname: Themes\Rozier\Explorer\SettingsProvider - */ - #[ - SymfonySerializer\SerializedName(serializedName: "settings"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_default"]), - \ApiPlatform\Metadata\ApiProperty(description: "Settings"), - SymfonySerializer\MaxDepth(2), - Gedmo\Versioned, - ORM\Column(name: "settings", type: "json", nullable: true), - Serializer\Groups(["nodes_sources", "nodes_sources_default"]), - Serializer\MaxDepth(2) - ] - private $settings = null; - /** * @return mixed */ - public function getSettings() + public function getSettings(): mixed { return $this->settings; } /** - * @param mixed $settings - * * @return $this */ - public function setSettings($settings): static + public function setSettings(mixed $settings): static { $this->settings = $settings; - return $this; } - - /** - * Folder simple. - * Default values: classname: Themes\Rozier\Explorer\FoldersProvider - */ - #[ - SymfonySerializer\SerializedName(serializedName: "folder"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_default"]), - \ApiPlatform\Metadata\ApiProperty(description: "Folder simple"), - SymfonySerializer\MaxDepth(2), - Gedmo\Versioned, - ORM\Column( - name: "folder", - type: "string", - nullable: true, - length: 250 - ), - Serializer\Groups(["nodes_sources", "nodes_sources_default"]), - Serializer\MaxDepth(2) - ] - private $folder = null; - /** * @return mixed */ - public function getFolder() + public function getFolder(): mixed { return $this->folder; } /** - * @param mixed $folder - * * @return $this */ - public function setFolder($folder): static + public function setFolder(mixed $folder): static { $this->folder = $folder; - return $this; } - - /** - * Country. - */ - #[ - SymfonySerializer\SerializedName(serializedName: "country"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_default"]), - \ApiPlatform\Metadata\ApiProperty(description: "Country"), - SymfonySerializer\MaxDepth(2), - Gedmo\Versioned, - ORM\Column( - name: "country", - type: "string", - nullable: true, - length: 5 - ), - Serializer\Groups(["nodes_sources", "nodes_sources_default"]), - Serializer\MaxDepth(2), - Serializer\Type("string") - ] - private ?string $country = null; - /** * @return string|null */ @@ -952,117 +862,50 @@ public function getCountry(): ?string } /** - * @param string|null $country - * * @return $this */ public function setCountry(?string $country): static { $this->country = null !== $country ? - (string) $country : - null; - + (string) $country : + null; return $this; } - - /** - * Geolocation. - */ - #[ - SymfonySerializer\SerializedName(serializedName: "geolocation"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_default"]), - \ApiPlatform\Metadata\ApiProperty(description: "Geolocation"), - SymfonySerializer\MaxDepth(2), - Gedmo\Versioned, - ORM\Column(name: "geolocation", type: "json", nullable: true), - Serializer\Groups(["nodes_sources", "nodes_sources_default"]), - Serializer\MaxDepth(2) - ] - private $geolocation = null; - /** * @return mixed */ - public function getGeolocation() + public function getGeolocation(): mixed { return $this->geolocation; } /** - * @param mixed $geolocation - * * @return $this */ - public function setGeolocation($geolocation): static + public function setGeolocation(mixed $geolocation): static { $this->geolocation = $geolocation; - return $this; } - - /** - * Multi geolocations. - * Group: Geo. - */ - #[ - SymfonySerializer\SerializedName(serializedName: "multiGeolocation"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_geo"]), - \ApiPlatform\Metadata\ApiProperty(description: "Multi geolocations"), - SymfonySerializer\MaxDepth(2), - Gedmo\Versioned, - ORM\Column(name: "multi_geolocation", type: "json", nullable: true), - Serializer\Groups(["nodes_sources", "nodes_sources_geo"]), - Serializer\MaxDepth(2) - ] - private $multiGeolocation = null; - /** * @return mixed */ - public function getMultiGeolocation() + public function getMultiGeolocation(): mixed { return $this->multiGeolocation; } /** - * @param mixed $multiGeolocation - * * @return $this */ - public function setMultiGeolocation($multiGeolocation): static + public function setMultiGeolocation(mixed $multiGeolocation): static { $this->multiGeolocation = $multiGeolocation; - return $this; } - - /** - * Layout. - * Default values: dark, transparent - */ - #[ - SymfonySerializer\SerializedName(serializedName: "layout"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_default"]), - \ApiPlatform\Metadata\ApiProperty(description: "Layout", schema: ["type" => "string", "enum" => ["dark","transparent"], "example" => "dark"], example: "light"), - SymfonySerializer\MaxDepth(2), - ApiFilter(OrmFilter\SearchFilter::class, strategy: "exact"), - ApiFilter(\RZ\Roadiz\CoreBundle\Api\Filter\NotFilter::class), - Gedmo\Versioned, - ORM\Column( - name: "layout", - type: "string", - nullable: true, - length: 11 - ), - Serializer\Groups(["nodes_sources", "nodes_sources_default"]), - Serializer\MaxDepth(2), - Serializer\Type("string") - ] - private ?string $layout = null; - /** * @return string|null */ @@ -1072,88 +915,56 @@ public function getLayout(): ?string } /** - * @param string|null $layout - * * @return $this */ public function setLayout(?string $layout): static { $this->layout = null !== $layout ? - (string) $layout : - null; - + (string) $layout : + null; return $this; } - - /** - * Main user. - * Default values: # Entity class name - * classname: \RZ\Roadiz\CoreBundle\Entity\User - * # Displayable is the method used to display entity name - * displayable: getUsername - * # Same as Displayable but for a secondary information - * alt_displayable: getEmail - * # Same as Displayable but for a secondary information - * thumbnail: ~ - * # Searchable entity fields - * searchable: - * - username - * - email - * # This order will only be used for explorer - * orderBy: - * - field: email - * direction: ASC - * @var \RZ\Roadiz\CoreBundle\Entity\User|null - */ - #[ - SymfonySerializer\SerializedName(serializedName: "mainUser"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_default"]), - \ApiPlatform\Metadata\ApiProperty(description: "Main user"), - SymfonySerializer\MaxDepth(2), - ORM\ManyToOne(targetEntity: \RZ\Roadiz\CoreBundle\Entity\User::class), - ORM\JoinColumn(name: "main_user_id", referencedColumnName: "id", onDelete: "SET NULL"), - ApiFilter(OrmFilter\SearchFilter::class, strategy: "exact"), - Serializer\Groups(["nodes_sources", "nodes_sources_default"]), - Serializer\MaxDepth(2) - ] - private ?\RZ\Roadiz\CoreBundle\Entity\User $mainUser = null; - - /** - * @return \RZ\Roadiz\CoreBundle\Entity\User|null - */ public function getMainUser(): ?\RZ\Roadiz\CoreBundle\Entity\User { return $this->mainUser; } /** - * @param \RZ\Roadiz\CoreBundle\Entity\User|null $mainUser * @return $this */ - public function setMainUser(?\RZ\Roadiz\CoreBundle\Entity\User $mainUser = null): static + public function setMainUser(?\RZ\Roadiz\CoreBundle\Entity\User $mainUser): static { $this->mainUser = $mainUser; - return $this; } - - public function __construct(\RZ\Roadiz\CoreBundle\Entity\Node $node, \RZ\Roadiz\CoreBundle\Entity\Translation $translation) + public function __construct(Node $node, Translation $translation) { parent::__construct($node, $translation); - $this->usersProxy = new \Doctrine\Common\Collections\ArrayCollection(); $this->folderReferences = new \Doctrine\Common\Collections\ArrayCollection(); } - #[ - Serializer\VirtualProperty, - Serializer\Groups(["nodes_sources", "nodes_sources_default"]), - Serializer\SerializedName("@type"), - SymfonySerializer\Groups(["nodes_sources", "nodes_sources_default"]), - SymfonySerializer\SerializedName(serializedName: "@type") - ] + public function __clone(): void + { + parent::__clone(); + + $usersProxyClone = new \Doctrine\Common\Collections\ArrayCollection(); + foreach ($this->usersProxy as $item) { + $itemClone = clone $item; + $itemClone->setNodeSource($this); + $usersProxyClone->add($itemClone); + $this->objectManager->persist($itemClone); + } + $this->usersProxy = $usersProxyClone; + } + + #[JMS\VirtualProperty] + #[JMS\Groups(['nodes_sources', 'nodes_sources_default'])] + #[JMS\SerializedName('@type')] + #[Serializer\Groups(['nodes_sources', 'nodes_sources_default'])] + #[Serializer\SerializedName(serializedName: '@type')] public function getNodeTypeName(): string { return 'Page'; @@ -1161,9 +972,9 @@ public function getNodeTypeName(): string /** * $this->nodeType->isReachable() proxy. - * * @return bool Does this nodeSource is reachable over network? */ + #[JMS\VirtualProperty] public function isReachable(): bool { return true; @@ -1171,28 +982,14 @@ public function isReachable(): bool /** * $this->nodeType->isPublishable() proxy. - * * @return bool Does this nodeSource is publishable with date and time? */ + #[JMS\VirtualProperty] public function isPublishable(): bool { return true; } - public function __clone() - { - parent::__clone(); - - $usersProxyClone = new \Doctrine\Common\Collections\ArrayCollection(); - foreach ($this->usersProxy as $item) { - $itemClone = clone $item; - $itemClone->setNodeSource($this); - $usersProxyClone->add($itemClone); - $this->objectManager->persist($itemClone); - } - $this->usersProxy = $usersProxyClone; - } - public function __toString(): string { return '[NSPage] ' . parent::__toString(); diff --git a/src/GeneratedEntity/Repository/NSArticleContainerRepository.php b/src/GeneratedEntity/Repository/NSArticleContainerRepository.php index f889b4b7..eba216cd 100644 --- a/src/GeneratedEntity/Repository/NSArticleContainerRepository.php +++ b/src/GeneratedEntity/Repository/NSArticleContainerRepository.php @@ -1,13 +1,15 @@ - * - * @method \App\GeneratedEntity\NSArticleContainer|null find($id, $lockMode = null, $lockVersion = null) - * @method \App\GeneratedEntity\NSArticleContainer|null findOneBy(array $criteria, array $orderBy = null) - * @method \App\GeneratedEntity\NSArticleContainer[] findAll() - * @method \App\GeneratedEntity\NSArticleContainer[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) + * @extends \RZ\Roadiz\CoreBundle\Repository\NodesSourcesRepository + * @method NSArticleContainer|null find($id, $lockMode = null, $lockVersion = null) + * @method NSArticleContainer|null findOneBy(array $criteria, array $orderBy = null) + * @method NSArticleContainer[] findAll() + * @method NSArticleContainer[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) */ -class NSArticleContainerRepository extends \RZ\Roadiz\CoreBundle\Repository\NodesSourcesRepository +final class NSArticleContainerRepository extends \RZ\Roadiz\CoreBundle\Repository\NodesSourcesRepository { public function __construct( ManagerRegistry $registry, PreviewResolverInterface $previewResolver, EventDispatcherInterface $dispatcher, Security $security, - ?NodeSourceSearchHandlerInterface $nodeSourceSearchHandler + ?NodeSourceSearchHandlerInterface $nodeSourceSearchHandler, ) { - parent::__construct($registry, $previewResolver, $dispatcher, $security, $nodeSourceSearchHandler, \App\GeneratedEntity\NSArticleContainer::class); + parent::__construct($registry, $previewResolver, $dispatcher, $security, $nodeSourceSearchHandler, NSArticleContainer::class); } } diff --git a/src/GeneratedEntity/Repository/NSArticleFeedBlockRepository.php b/src/GeneratedEntity/Repository/NSArticleFeedBlockRepository.php index 706789f2..fbca3db1 100644 --- a/src/GeneratedEntity/Repository/NSArticleFeedBlockRepository.php +++ b/src/GeneratedEntity/Repository/NSArticleFeedBlockRepository.php @@ -1,13 +1,15 @@ - * - * @method \App\GeneratedEntity\NSArticleFeedBlock|null find($id, $lockMode = null, $lockVersion = null) - * @method \App\GeneratedEntity\NSArticleFeedBlock|null findOneBy(array $criteria, array $orderBy = null) - * @method \App\GeneratedEntity\NSArticleFeedBlock[] findAll() - * @method \App\GeneratedEntity\NSArticleFeedBlock[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) + * @extends \RZ\Roadiz\CoreBundle\Repository\NodesSourcesRepository + * @method NSArticleFeedBlock|null find($id, $lockMode = null, $lockVersion = null) + * @method NSArticleFeedBlock|null findOneBy(array $criteria, array $orderBy = null) + * @method NSArticleFeedBlock[] findAll() + * @method NSArticleFeedBlock[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) */ -class NSArticleFeedBlockRepository extends \RZ\Roadiz\CoreBundle\Repository\NodesSourcesRepository +final class NSArticleFeedBlockRepository extends \RZ\Roadiz\CoreBundle\Repository\NodesSourcesRepository { public function __construct( ManagerRegistry $registry, PreviewResolverInterface $previewResolver, EventDispatcherInterface $dispatcher, Security $security, - ?NodeSourceSearchHandlerInterface $nodeSourceSearchHandler + ?NodeSourceSearchHandlerInterface $nodeSourceSearchHandler, ) { - parent::__construct($registry, $previewResolver, $dispatcher, $security, $nodeSourceSearchHandler, \App\GeneratedEntity\NSArticleFeedBlock::class); + parent::__construct($registry, $previewResolver, $dispatcher, $security, $nodeSourceSearchHandler, NSArticleFeedBlock::class); } } diff --git a/src/GeneratedEntity/Repository/NSArticleRepository.php b/src/GeneratedEntity/Repository/NSArticleRepository.php index 4aa05bc3..3488b764 100644 --- a/src/GeneratedEntity/Repository/NSArticleRepository.php +++ b/src/GeneratedEntity/Repository/NSArticleRepository.php @@ -1,13 +1,15 @@ - * - * @method \App\GeneratedEntity\NSArticle|null find($id, $lockMode = null, $lockVersion = null) - * @method \App\GeneratedEntity\NSArticle|null findOneBy(array $criteria, array $orderBy = null) - * @method \App\GeneratedEntity\NSArticle[] findAll() - * @method \App\GeneratedEntity\NSArticle[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) + * @extends \RZ\Roadiz\CoreBundle\Repository\NodesSourcesRepository + * @method NSArticle|null find($id, $lockMode = null, $lockVersion = null) + * @method NSArticle|null findOneBy(array $criteria, array $orderBy = null) + * @method NSArticle[] findAll() + * @method NSArticle[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) */ -class NSArticleRepository extends \RZ\Roadiz\CoreBundle\Repository\NodesSourcesRepository +final class NSArticleRepository extends \RZ\Roadiz\CoreBundle\Repository\NodesSourcesRepository { public function __construct( ManagerRegistry $registry, PreviewResolverInterface $previewResolver, EventDispatcherInterface $dispatcher, Security $security, - ?NodeSourceSearchHandlerInterface $nodeSourceSearchHandler + ?NodeSourceSearchHandlerInterface $nodeSourceSearchHandler, ) { - parent::__construct($registry, $previewResolver, $dispatcher, $security, $nodeSourceSearchHandler, \App\GeneratedEntity\NSArticle::class); + parent::__construct($registry, $previewResolver, $dispatcher, $security, $nodeSourceSearchHandler, NSArticle::class); } } diff --git a/src/GeneratedEntity/Repository/NSBasicBlockRepository.php b/src/GeneratedEntity/Repository/NSBasicBlockRepository.php index ce7c484f..4737a518 100644 --- a/src/GeneratedEntity/Repository/NSBasicBlockRepository.php +++ b/src/GeneratedEntity/Repository/NSBasicBlockRepository.php @@ -1,13 +1,15 @@ - * - * @method \App\GeneratedEntity\NSBasicBlock|null find($id, $lockMode = null, $lockVersion = null) - * @method \App\GeneratedEntity\NSBasicBlock|null findOneBy(array $criteria, array $orderBy = null) - * @method \App\GeneratedEntity\NSBasicBlock[] findAll() - * @method \App\GeneratedEntity\NSBasicBlock[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) + * @extends \RZ\Roadiz\CoreBundle\Repository\NodesSourcesRepository + * @method NSBasicBlock|null find($id, $lockMode = null, $lockVersion = null) + * @method NSBasicBlock|null findOneBy(array $criteria, array $orderBy = null) + * @method NSBasicBlock[] findAll() + * @method NSBasicBlock[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) */ -class NSBasicBlockRepository extends \RZ\Roadiz\CoreBundle\Repository\NodesSourcesRepository +final class NSBasicBlockRepository extends \RZ\Roadiz\CoreBundle\Repository\NodesSourcesRepository { public function __construct( ManagerRegistry $registry, PreviewResolverInterface $previewResolver, EventDispatcherInterface $dispatcher, Security $security, - ?NodeSourceSearchHandlerInterface $nodeSourceSearchHandler + ?NodeSourceSearchHandlerInterface $nodeSourceSearchHandler, ) { - parent::__construct($registry, $previewResolver, $dispatcher, $security, $nodeSourceSearchHandler, \App\GeneratedEntity\NSBasicBlock::class); + parent::__construct($registry, $previewResolver, $dispatcher, $security, $nodeSourceSearchHandler, NSBasicBlock::class); } } diff --git a/src/GeneratedEntity/Repository/NSGroupBlockRepository.php b/src/GeneratedEntity/Repository/NSGroupBlockRepository.php index 9429582e..8b91b1ed 100644 --- a/src/GeneratedEntity/Repository/NSGroupBlockRepository.php +++ b/src/GeneratedEntity/Repository/NSGroupBlockRepository.php @@ -1,13 +1,15 @@ - * - * @method \App\GeneratedEntity\NSGroupBlock|null find($id, $lockMode = null, $lockVersion = null) - * @method \App\GeneratedEntity\NSGroupBlock|null findOneBy(array $criteria, array $orderBy = null) - * @method \App\GeneratedEntity\NSGroupBlock[] findAll() - * @method \App\GeneratedEntity\NSGroupBlock[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) + * @extends \RZ\Roadiz\CoreBundle\Repository\NodesSourcesRepository + * @method NSGroupBlock|null find($id, $lockMode = null, $lockVersion = null) + * @method NSGroupBlock|null findOneBy(array $criteria, array $orderBy = null) + * @method NSGroupBlock[] findAll() + * @method NSGroupBlock[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) */ -class NSGroupBlockRepository extends \RZ\Roadiz\CoreBundle\Repository\NodesSourcesRepository +final class NSGroupBlockRepository extends \RZ\Roadiz\CoreBundle\Repository\NodesSourcesRepository { public function __construct( ManagerRegistry $registry, PreviewResolverInterface $previewResolver, EventDispatcherInterface $dispatcher, Security $security, - ?NodeSourceSearchHandlerInterface $nodeSourceSearchHandler + ?NodeSourceSearchHandlerInterface $nodeSourceSearchHandler, ) { - parent::__construct($registry, $previewResolver, $dispatcher, $security, $nodeSourceSearchHandler, \App\GeneratedEntity\NSGroupBlock::class); + parent::__construct($registry, $previewResolver, $dispatcher, $security, $nodeSourceSearchHandler, NSGroupBlock::class); } } diff --git a/src/GeneratedEntity/Repository/NSMenuLinkRepository.php b/src/GeneratedEntity/Repository/NSMenuLinkRepository.php index ca38d53a..2d14e973 100644 --- a/src/GeneratedEntity/Repository/NSMenuLinkRepository.php +++ b/src/GeneratedEntity/Repository/NSMenuLinkRepository.php @@ -1,13 +1,15 @@ - * - * @method \App\GeneratedEntity\NSMenuLink|null find($id, $lockMode = null, $lockVersion = null) - * @method \App\GeneratedEntity\NSMenuLink|null findOneBy(array $criteria, array $orderBy = null) - * @method \App\GeneratedEntity\NSMenuLink[] findAll() - * @method \App\GeneratedEntity\NSMenuLink[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) + * @extends \RZ\Roadiz\CoreBundle\Repository\NodesSourcesRepository + * @method NSMenuLink|null find($id, $lockMode = null, $lockVersion = null) + * @method NSMenuLink|null findOneBy(array $criteria, array $orderBy = null) + * @method NSMenuLink[] findAll() + * @method NSMenuLink[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) */ -class NSMenuLinkRepository extends \RZ\Roadiz\CoreBundle\Repository\NodesSourcesRepository +final class NSMenuLinkRepository extends \RZ\Roadiz\CoreBundle\Repository\NodesSourcesRepository { public function __construct( ManagerRegistry $registry, PreviewResolverInterface $previewResolver, EventDispatcherInterface $dispatcher, Security $security, - ?NodeSourceSearchHandlerInterface $nodeSourceSearchHandler + ?NodeSourceSearchHandlerInterface $nodeSourceSearchHandler, ) { - parent::__construct($registry, $previewResolver, $dispatcher, $security, $nodeSourceSearchHandler, \App\GeneratedEntity\NSMenuLink::class); + parent::__construct($registry, $previewResolver, $dispatcher, $security, $nodeSourceSearchHandler, NSMenuLink::class); } } diff --git a/src/GeneratedEntity/Repository/NSMenuRepository.php b/src/GeneratedEntity/Repository/NSMenuRepository.php index 1a6f1061..3729657e 100644 --- a/src/GeneratedEntity/Repository/NSMenuRepository.php +++ b/src/GeneratedEntity/Repository/NSMenuRepository.php @@ -1,13 +1,15 @@ - * - * @method \App\GeneratedEntity\NSMenu|null find($id, $lockMode = null, $lockVersion = null) - * @method \App\GeneratedEntity\NSMenu|null findOneBy(array $criteria, array $orderBy = null) - * @method \App\GeneratedEntity\NSMenu[] findAll() - * @method \App\GeneratedEntity\NSMenu[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) + * @extends \RZ\Roadiz\CoreBundle\Repository\NodesSourcesRepository + * @method NSMenu|null find($id, $lockMode = null, $lockVersion = null) + * @method NSMenu|null findOneBy(array $criteria, array $orderBy = null) + * @method NSMenu[] findAll() + * @method NSMenu[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) */ -class NSMenuRepository extends \RZ\Roadiz\CoreBundle\Repository\NodesSourcesRepository +final class NSMenuRepository extends \RZ\Roadiz\CoreBundle\Repository\NodesSourcesRepository { public function __construct( ManagerRegistry $registry, PreviewResolverInterface $previewResolver, EventDispatcherInterface $dispatcher, Security $security, - ?NodeSourceSearchHandlerInterface $nodeSourceSearchHandler + ?NodeSourceSearchHandlerInterface $nodeSourceSearchHandler, ) { - parent::__construct($registry, $previewResolver, $dispatcher, $security, $nodeSourceSearchHandler, \App\GeneratedEntity\NSMenu::class); + parent::__construct($registry, $previewResolver, $dispatcher, $security, $nodeSourceSearchHandler, NSMenu::class); } } diff --git a/src/GeneratedEntity/Repository/NSNeutralRepository.php b/src/GeneratedEntity/Repository/NSNeutralRepository.php index d501bb4b..2d72597c 100644 --- a/src/GeneratedEntity/Repository/NSNeutralRepository.php +++ b/src/GeneratedEntity/Repository/NSNeutralRepository.php @@ -1,13 +1,15 @@ - * - * @method \App\GeneratedEntity\NSNeutral|null find($id, $lockMode = null, $lockVersion = null) - * @method \App\GeneratedEntity\NSNeutral|null findOneBy(array $criteria, array $orderBy = null) - * @method \App\GeneratedEntity\NSNeutral[] findAll() - * @method \App\GeneratedEntity\NSNeutral[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) + * @extends \RZ\Roadiz\CoreBundle\Repository\NodesSourcesRepository + * @method NSNeutral|null find($id, $lockMode = null, $lockVersion = null) + * @method NSNeutral|null findOneBy(array $criteria, array $orderBy = null) + * @method NSNeutral[] findAll() + * @method NSNeutral[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) */ -class NSNeutralRepository extends \RZ\Roadiz\CoreBundle\Repository\NodesSourcesRepository +final class NSNeutralRepository extends \RZ\Roadiz\CoreBundle\Repository\NodesSourcesRepository { public function __construct( ManagerRegistry $registry, PreviewResolverInterface $previewResolver, EventDispatcherInterface $dispatcher, Security $security, - ?NodeSourceSearchHandlerInterface $nodeSourceSearchHandler + ?NodeSourceSearchHandlerInterface $nodeSourceSearchHandler, ) { - parent::__construct($registry, $previewResolver, $dispatcher, $security, $nodeSourceSearchHandler, \App\GeneratedEntity\NSNeutral::class); + parent::__construct($registry, $previewResolver, $dispatcher, $security, $nodeSourceSearchHandler, NSNeutral::class); } } diff --git a/src/GeneratedEntity/Repository/NSOfferRepository.php b/src/GeneratedEntity/Repository/NSOfferRepository.php index dc8c574f..744612db 100644 --- a/src/GeneratedEntity/Repository/NSOfferRepository.php +++ b/src/GeneratedEntity/Repository/NSOfferRepository.php @@ -1,13 +1,15 @@ - * - * @method \App\GeneratedEntity\NSOffer|null find($id, $lockMode = null, $lockVersion = null) - * @method \App\GeneratedEntity\NSOffer|null findOneBy(array $criteria, array $orderBy = null) - * @method \App\GeneratedEntity\NSOffer[] findAll() - * @method \App\GeneratedEntity\NSOffer[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) + * @extends \RZ\Roadiz\CoreBundle\Repository\NodesSourcesRepository + * @method NSOffer|null find($id, $lockMode = null, $lockVersion = null) + * @method NSOffer|null findOneBy(array $criteria, array $orderBy = null) + * @method NSOffer[] findAll() + * @method NSOffer[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) */ -class NSOfferRepository extends \RZ\Roadiz\CoreBundle\Repository\NodesSourcesRepository +final class NSOfferRepository extends \RZ\Roadiz\CoreBundle\Repository\NodesSourcesRepository { public function __construct( ManagerRegistry $registry, PreviewResolverInterface $previewResolver, EventDispatcherInterface $dispatcher, Security $security, - ?NodeSourceSearchHandlerInterface $nodeSourceSearchHandler + ?NodeSourceSearchHandlerInterface $nodeSourceSearchHandler, ) { - parent::__construct($registry, $previewResolver, $dispatcher, $security, $nodeSourceSearchHandler, \App\GeneratedEntity\NSOffer::class); + parent::__construct($registry, $previewResolver, $dispatcher, $security, $nodeSourceSearchHandler, NSOffer::class); } } diff --git a/src/GeneratedEntity/Repository/NSPageRepository.php b/src/GeneratedEntity/Repository/NSPageRepository.php index 4d41f56b..4686698c 100644 --- a/src/GeneratedEntity/Repository/NSPageRepository.php +++ b/src/GeneratedEntity/Repository/NSPageRepository.php @@ -1,13 +1,15 @@ - * - * @method \App\GeneratedEntity\NSPage|null find($id, $lockMode = null, $lockVersion = null) - * @method \App\GeneratedEntity\NSPage|null findOneBy(array $criteria, array $orderBy = null) - * @method \App\GeneratedEntity\NSPage[] findAll() - * @method \App\GeneratedEntity\NSPage[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) + * @extends \RZ\Roadiz\CoreBundle\Repository\NodesSourcesRepository + * @method NSPage|null find($id, $lockMode = null, $lockVersion = null) + * @method NSPage|null findOneBy(array $criteria, array $orderBy = null) + * @method NSPage[] findAll() + * @method NSPage[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) */ -class NSPageRepository extends \RZ\Roadiz\CoreBundle\Repository\NodesSourcesRepository +final class NSPageRepository extends \RZ\Roadiz\CoreBundle\Repository\NodesSourcesRepository { public function __construct( ManagerRegistry $registry, PreviewResolverInterface $previewResolver, EventDispatcherInterface $dispatcher, Security $security, - ?NodeSourceSearchHandlerInterface $nodeSourceSearchHandler + ?NodeSourceSearchHandlerInterface $nodeSourceSearchHandler, ) { - parent::__construct($registry, $previewResolver, $dispatcher, $security, $nodeSourceSearchHandler, \App\GeneratedEntity\NSPage::class); + parent::__construct($registry, $previewResolver, $dispatcher, $security, $nodeSourceSearchHandler, NSPage::class); } }