diff --git a/config/api_resources/nodes_sources.yml b/config/api_resources/nodes_sources.yml index 2fcc6829e..340619ea4 100644 --- a/config/api_resources/nodes_sources.yml +++ b/config/api_resources/nodes_sources.yml @@ -34,33 +34,33 @@ resources: description: | Get available NodesSources archives (years and months) based on their `publishedAt` field -# api_nodes_sources_search: -# class: ApiPlatform\Metadata\GetCollection -# method: 'GET' -# uriTemplate: '/nodes_sources/search' -# controller: RZ\Roadiz\SolrBundle\Controller\NodesSourcesSearchController -# read: false -# normalizationContext: -# groups: -# - get -# - nodes_sources_base -# - nodes_sources_default -# - urls -# - tag_base -# - translation_base -# - document_display -# openapi: -# summary: Search NodesSources resources -# description: | -# Search all website NodesSources resources using **Solr** full-text search engine -# parameters: -# - type: string -# name: search -# in: query -# required: true -# description: Search pattern -# schema: -# type: string + api_nodes_sources_search: + class: ApiPlatform\Metadata\GetCollection + method: 'GET' + uriTemplate: '/nodes_sources/search' + controller: RZ\Roadiz\SolrBundle\Controller\NodesSourcesSearchController + read: false + normalizationContext: + groups: + - get + - nodes_sources_base + - nodes_sources_default + - urls + - tag_base + - translation_base + - document_display + openapi: + summary: Search NodesSources resources + description: | + Search all website NodesSources resources using **Solr** full-text search engine + parameters: + - type: string + name: search + in: query + required: true + description: Search pattern + schema: + type: string # ApiPlatform\Metadata\Get: # method: 'GET' diff --git a/config/packages/roadiz_solr.yaml b/config/packages/roadiz_solr.yaml new file mode 100644 index 000000000..2df177f7e --- /dev/null +++ b/config/packages/roadiz_solr.yaml @@ -0,0 +1,4 @@ +roadiz_solr: + search: + fuzzy_proximity: 2 + fuzzy_min_term_length: 3 diff --git a/docs/developer/first-steps/use_apache_solr.md b/docs/developer/first-steps/use_apache_solr.md index cecb05ace..49c8903d8 100644 --- a/docs/developer/first-steps/use_apache_solr.md +++ b/docs/developer/first-steps/use_apache_solr.md @@ -53,10 +53,23 @@ nelmio_solarium: adapter_timeout: 5 ``` +Then configure fuzzy search options in `config/packages/roadiz_solr.yaml`: + +```yaml +# config/packages/roadiz_solr.yaml +roadiz_solr: + search: + fuzzy_proximity: 2 + fuzzy_min_term_length: 3 +``` + You can use Solr in 2 ways: as a core or as a collection: - If you are using Solr as a single core, you can set the `SOLR_CORE_NAME` environment variable. - If you are using _SolrCloud mode_, you can set the `SOLR_COLLECTION_NAME` +Fuzzy search options are configured in `roadiz_solr.search`. +For backward compatibility, `roadiz_core.solr.search` is still read as a fallback during migration. + ::: info When using _SolrCloud mode_ you will need to set the `SOLR_COLLECTION_NUM_SHARDS` and `SOLR_COLLECTION_REPLICATION_FACTOR` variables to configure your collection and execute diff --git a/lib/Documents/src/Console/DocumentSizeCommand.php b/lib/Documents/src/Console/DocumentSizeCommand.php index 0b18b80b3..a9f6c85e1 100644 --- a/lib/Documents/src/Console/DocumentSizeCommand.php +++ b/lib/Documents/src/Console/DocumentSizeCommand.php @@ -39,7 +39,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int private function updateDocumentSize(DocumentInterface $document): void { - if (!($document instanceof SizeableInterface)) { + if (!$document instanceof SizeableInterface) { return; } $mountPath = $document->getMountPath(); diff --git a/lib/Documents/src/MediaFinders/AbstractYoutubeEmbedFinder.php b/lib/Documents/src/MediaFinders/AbstractYoutubeEmbedFinder.php index e0206f26c..654681942 100644 --- a/lib/Documents/src/MediaFinders/AbstractYoutubeEmbedFinder.php +++ b/lib/Documents/src/MediaFinders/AbstractYoutubeEmbedFinder.php @@ -157,9 +157,8 @@ public function getSearchFeed(string $searchTerm, ?string $author = null, int $m } return $this->downloadFeedFromAPI($url); - } else { - throw new APINeedsAuthentificationException('YoutubeEmbedFinder needs a Google server key, create a “google_server_id” setting.', 1); } + throw new APINeedsAuthentificationException('YoutubeEmbedFinder needs a Google server key, create a “google_server_id” setting.', 1); } /** diff --git a/lib/Documents/src/Models/BaseDocumentTrait.php b/lib/Documents/src/Models/BaseDocumentTrait.php index ecaef4bbe..6ee7d4080 100644 --- a/lib/Documents/src/Models/BaseDocumentTrait.php +++ b/lib/Documents/src/Models/BaseDocumentTrait.php @@ -153,10 +153,8 @@ trait BaseDocumentTrait 'image/heif', ]; - #[ - Serializer\Groups(['document_mount']), - Serializer\SerializedName('mountPath'), - ] + #[Serializer\Groups(['document_mount']), + Serializer\SerializedName('mountPath'),] public function getMountPath(): ?string { if (null === $relativePath = $this->getRelativePath()) { @@ -164,25 +162,23 @@ public function getMountPath(): ?string } if ($this->isPrivate()) { return 'private://'.$relativePath; - } else { - return 'public://'.$relativePath; } + + return 'public://'.$relativePath; } /** * Get short type name for current document Mime type. */ - #[ - Serializer\Groups(['document', 'document_display', 'nodes_sources', 'tag', 'attribute']), - Serializer\SerializedName('type'), - ] + #[Serializer\Groups(['document', 'document_display', 'nodes_sources', 'tag', 'attribute']), + Serializer\SerializedName('type'),] public function getShortType(): string { if (null !== $this->getMimeType() && isset(static::$mimeToIcon[$this->getMimeType()])) { return static::$mimeToIcon[$this->getMimeType()]; - } else { - return 'unknown'; } + + return 'unknown'; } /** @@ -251,32 +247,26 @@ public function isWebp(): bool return 'image/webp' === $this->getMimeType(); } - #[ - Serializer\Groups(['document', 'document_display', 'nodes_sources', 'tag', 'attribute']), - Serializer\SerializedName('relativePath'), - ] + #[Serializer\Groups(['document', 'document_display', 'nodes_sources', 'tag', 'attribute']), + Serializer\SerializedName('relativePath'),] public function getRelativePath(): ?string { return $this->isLocal() ? $this->getFolder().'/'.$this->getFilename() : null; } - #[ - Serializer\Groups(['document', 'document_display', 'nodes_sources', 'tag', 'attribute']), + #[Serializer\Groups(['document', 'document_display', 'nodes_sources', 'tag', 'attribute']), Serializer\SerializedName('processable'), ApiProperty( description: 'Document can be processed as an image for resampling and other image operations.', writable: false, - ) - ] + )] public function isProcessable(): bool { return !$this->isPrivate() && $this->isImage() && in_array($this->getMimeType(), static::$processableMimeTypes, true); } - #[ - Serializer\Groups(['document', 'document_display', 'nodes_sources', 'tag', 'attribute']), - Serializer\SerializedName('alt'), - ] + #[Serializer\Groups(['document', 'document_display', 'nodes_sources', 'tag', 'attribute']), + Serializer\SerializedName('alt'),] public function getAlternativeText(): ?string { return null; diff --git a/lib/Documents/src/Models/DocumentTrait.php b/lib/Documents/src/Models/DocumentTrait.php index 11cf980a4..f5ad64aa2 100644 --- a/lib/Documents/src/Models/DocumentTrait.php +++ b/lib/Documents/src/Models/DocumentTrait.php @@ -9,9 +9,7 @@ trait DocumentTrait { - #[ - Serializer\Ignore - ] + #[Serializer\Ignore] public function getMountFolderPath(): ?string { $folder = $this->getFolder(); @@ -20,9 +18,9 @@ public function getMountFolderPath(): ?string } if ($this->isPrivate()) { return 'private://'.$folder; - } else { - return 'public://'.$folder; } + + return 'public://'.$folder; } protected function initDocumentTrait(): void diff --git a/lib/Documents/src/Renderer/AbstractImageRenderer.php b/lib/Documents/src/Renderer/AbstractImageRenderer.php index 9dc28a114..ce5681b1a 100644 --- a/lib/Documents/src/Renderer/AbstractImageRenderer.php +++ b/lib/Documents/src/Renderer/AbstractImageRenderer.php @@ -176,7 +176,7 @@ protected function additionalAssignation(BaseDocumentInterface $document, array $assignation['height'] = $options['height'] = $this->getImageHeight($options); } - if (!($document instanceof AdvancedDocumentInterface)) { + if (!$document instanceof AdvancedDocumentInterface) { return; } diff --git a/lib/Documents/src/Renderer/ChainRenderer.php b/lib/Documents/src/Renderer/ChainRenderer.php index a16cdcf50..fae69c76b 100644 --- a/lib/Documents/src/Renderer/ChainRenderer.php +++ b/lib/Documents/src/Renderer/ChainRenderer.php @@ -19,7 +19,7 @@ public function __construct(array $renderers) * @var RendererInterface $renderer */ foreach ($renderers as $renderer) { - if (!($renderer instanceof RendererInterface)) { + if (!$renderer instanceof RendererInterface) { throw new \InvalidArgumentException('Document Renderer must implement RendererInterface'); } } diff --git a/lib/Documents/src/Renderer/EmbedRenderer.php b/lib/Documents/src/Renderer/EmbedRenderer.php index 49b95558f..26e92af20 100644 --- a/lib/Documents/src/Renderer/EmbedRenderer.php +++ b/lib/Documents/src/Renderer/EmbedRenderer.php @@ -24,9 +24,9 @@ public function supports(BaseDocumentInterface $document, array $options): bool && true === $options['embed'] ) { return true; - } else { - return false; } + + return false; } #[\Override] diff --git a/lib/Documents/src/SvgSizeResolver.php b/lib/Documents/src/SvgSizeResolver.php index fa62ebd28..4cd0da206 100644 --- a/lib/Documents/src/SvgSizeResolver.php +++ b/lib/Documents/src/SvgSizeResolver.php @@ -22,7 +22,7 @@ public function __construct( /** * @return array|null [$x, $y, $width, $height] */ - protected function getViewBoxAttributes(): ?array + private function getViewBoxAttributes(): ?array { try { $viewBox = $this->getSvgNodeAttributes()->getNamedItem('viewBox'); @@ -36,7 +36,7 @@ protected function getViewBoxAttributes(): ?array return null; } - protected function getIntegerAttribute(string $name): ?int + private function getIntegerAttribute(string $name): ?int { try { $attribute = $this->getSvgNodeAttributes()->getNamedItem($name); diff --git a/lib/Documents/src/TwigExtension/DocumentExtension.php b/lib/Documents/src/TwigExtension/DocumentExtension.php index 8a8133abe..4a26ee480 100644 --- a/lib/Documents/src/TwigExtension/DocumentExtension.php +++ b/lib/Documents/src/TwigExtension/DocumentExtension.php @@ -67,9 +67,9 @@ public function getEmbedFinder(?BaseDocumentInterface $document = null): ?EmbedF if (null === $document) { if ($this->throwExceptions) { throw new RuntimeError('Document can’t be null to get its EmbedFinder.'); - } else { - return null; } + + return null; } try { @@ -85,9 +85,9 @@ public function getEmbedFinder(?BaseDocumentInterface $document = null): ?EmbedF } catch (InvalidEmbedId $embedException) { if ($this->throwExceptions) { throw new RuntimeError($embedException->getMessage()); - } else { - return null; } + + return null; } return null; @@ -101,9 +101,9 @@ public function display(?BaseDocumentInterface $document = null, ?array $options if (null === $document) { if ($this->throwExceptions) { throw new RuntimeError('Document can’t be null to be displayed.'); - } else { - return ''; } + + return ''; } if (null === $options) { $options = []; @@ -113,9 +113,9 @@ public function display(?BaseDocumentInterface $document = null, ?array $options } catch (InvalidEmbedId $embedException) { if ($this->throwExceptions) { throw new RuntimeError($embedException->getMessage()); - } else { - return '

'.$embedException->getMessage().'

'; } + + return '

'.$embedException->getMessage().'

'; } catch (InvalidArgumentException $e) { throw new RuntimeError($e->getMessage(), -1, null, $e); } @@ -135,9 +135,9 @@ public function getImageOrientation(?SizeableInterface $document = null): ?strin if (null === $document) { if ($this->throwExceptions) { throw new RuntimeError('Document can’t be null to get its orientation.'); - } else { - return null; } + + return null; } $size = $this->getImageSize($document); @@ -154,12 +154,12 @@ public function getImageSize(?SizeableInterface $document = null): array if (null === $document) { if ($this->throwExceptions) { throw new RuntimeError('Document can’t be null to get its size.'); - } else { - return [ - 'width' => 0, - 'height' => 0, - ]; } + + return [ + 'width' => 0, + 'height' => 0, + ]; } return [ @@ -176,9 +176,9 @@ public function getImageRatio(?SizeableInterface $document = null): float if (null === $document) { if ($this->throwExceptions) { throw new RuntimeError('Document can’t be null to get its ratio.'); - } else { - return 0.0; } + + return 0.0; } if (null !== $document && null !== $ratio = $document->getImageRatio()) { diff --git a/lib/Documents/src/UrlGenerators/AbstractDocumentUrlGenerator.php b/lib/Documents/src/UrlGenerators/AbstractDocumentUrlGenerator.php index 0fd58c831..20f9cc633 100644 --- a/lib/Documents/src/UrlGenerators/AbstractDocumentUrlGenerator.php +++ b/lib/Documents/src/UrlGenerators/AbstractDocumentUrlGenerator.php @@ -83,9 +83,9 @@ public function getUrl(bool $absolute = false): string $publicUrl = $this->documentsStorage->publicUrl($mountPath); if ($absolute && \str_starts_with($publicUrl, '/')) { return $this->urlHelper->getAbsoluteUrl($publicUrl); - } else { - return $publicUrl; } + + return $publicUrl; } return $this->getProcessedDocumentUrlByArray($absolute); diff --git a/lib/Documents/src/Viewers/SvgDocumentViewer.php b/lib/Documents/src/Viewers/SvgDocumentViewer.php index f4e82ba1c..fca1d1674 100644 --- a/lib/Documents/src/Viewers/SvgDocumentViewer.php +++ b/lib/Documents/src/Viewers/SvgDocumentViewer.php @@ -39,12 +39,12 @@ public function getContent(): string { if (false === $this->asObject) { return $this->getInlineSvg(); - } else { - return $this->getObjectSvg(); } + + return $this->getObjectSvg(); } - protected function getAllowedAttributes(): array + private function getAllowedAttributes(): array { $attributes = []; foreach ($this->attributes as $key => $value) { @@ -63,7 +63,7 @@ protected function getAllowedAttributes(): array /** * @throws FilesystemException */ - protected function getInlineSvg(): string + private function getInlineSvg(): string { $mountPath = $this->document->getMountPath(); @@ -95,7 +95,7 @@ protected function getInlineSvg(): string /** * @throws \Exception */ - protected function injectAttributes(string $svg): string + private function injectAttributes(string $svg): string { $attributes = $this->getAllowedAttributes(); if (count($attributes) > 0) { @@ -133,7 +133,7 @@ protected function injectAttributes(string $svg): string /** * @deprecated use SvgRenderer to render HTML object */ - protected function getObjectSvg(): string + private function getObjectSvg(): string { $mountPath = $this->document->getMountPath(); diff --git a/lib/DtsGenerator/src/Generators/NodeTypeGenerator.php b/lib/DtsGenerator/src/Generators/NodeTypeGenerator.php index fa4a46696..d612f00f9 100644 --- a/lib/DtsGenerator/src/Generators/NodeTypeGenerator.php +++ b/lib/DtsGenerator/src/Generators/NodeTypeGenerator.php @@ -51,7 +51,7 @@ public function getContents(): string ]); } - protected function getInterfaceBody(): string + private function getInterfaceBody(): string { $lines = [ 'export interface '.$this->nodeType->getSourceEntityClassName().' extends RoadizNodesSources {', @@ -62,7 +62,7 @@ protected function getInterfaceBody(): string return implode(PHP_EOL, $lines); } - protected function getIntroduction(): string + private function getIntroduction(): string { $lines = [ '', @@ -80,7 +80,7 @@ protected function getIntroduction(): string return implode(PHP_EOL, array_map(fn (string $line) => '// '.$line, $lines)); } - protected function getFieldsContents(): string + private function getFieldsContents(): string { return implode(PHP_EOL, array_map(fn (AbstractFieldGenerator $abstractFieldGenerator) => $abstractFieldGenerator->getContents(), $this->fieldGenerators)); } diff --git a/lib/Models/src/Core/AbstractEntities/AbstractDateTimed.php b/lib/Models/src/Core/AbstractEntities/AbstractDateTimed.php index fce850ab7..fc5b81df8 100644 --- a/lib/Models/src/Core/AbstractEntities/AbstractDateTimed.php +++ b/lib/Models/src/Core/AbstractEntities/AbstractDateTimed.php @@ -11,13 +11,11 @@ * * @deprecated since 2.6, use composition with DateTimedTrait instead. */ -#[ - ORM\MappedSuperclass, +#[ORM\MappedSuperclass, ORM\HasLifecycleCallbacks, ORM\Table, ORM\Index(columns: ['created_at']), - ORM\Index(columns: ['updated_at']), -] + ORM\Index(columns: ['updated_at']),] abstract class AbstractDateTimed extends AbstractEntity implements DateTimedInterface { use DateTimedTrait; diff --git a/lib/Models/src/Core/AbstractEntities/AbstractEntity.php b/lib/Models/src/Core/AbstractEntities/AbstractEntity.php index ac32fb515..744dce6ef 100644 --- a/lib/Models/src/Core/AbstractEntities/AbstractEntity.php +++ b/lib/Models/src/Core/AbstractEntities/AbstractEntity.php @@ -11,10 +11,8 @@ * * @deprecated since 2.6, use composition with PersistableInterface and SequentialIdTrait or UuidTrait instead. */ -#[ - ORM\MappedSuperclass, - ORM\Table -] +#[ORM\MappedSuperclass, + ORM\Table] abstract class AbstractEntity implements PersistableInterface { use SequentialIdTrait; diff --git a/lib/Models/src/Core/AbstractEntities/AbstractHuman.php b/lib/Models/src/Core/AbstractEntities/AbstractHuman.php index f6fe7abad..b31c77927 100644 --- a/lib/Models/src/Core/AbstractEntities/AbstractHuman.php +++ b/lib/Models/src/Core/AbstractEntities/AbstractHuman.php @@ -16,11 +16,9 @@ * * This class can be extended for *Users*, *Subscribers*, etc. */ -#[ - ORM\MappedSuperclass, +#[ORM\MappedSuperclass, ORM\Table, - ORM\HasLifecycleCallbacks -] + ORM\HasLifecycleCallbacks] abstract class AbstractHuman implements DateTimedInterface, PersistableInterface { use SequentialIdTrait; @@ -40,32 +38,24 @@ abstract class AbstractHuman implements DateTimedInterface, PersistableInterface /** * Public name (pseudonyme) that can be displayed to a public audience. */ - #[ - ORM\Column(name: 'publicName', type: 'string', length: 250, nullable: true), + #[ORM\Column(name: 'publicName', type: 'string', length: 250, nullable: true), Serializer\Groups(['user_public', 'human']), - Assert\Length(max: 250) - ] + Assert\Length(max: 250)] protected ?string $publicName = null; - #[ - ORM\Column(name: 'firstName', type: 'string', length: 250, nullable: true), + #[ORM\Column(name: 'firstName', type: 'string', length: 250, nullable: true), Serializer\Groups(['user_personal', 'human']), - Assert\Length(max: 250) - ] + Assert\Length(max: 250)] protected ?string $firstName = null; - #[ - ORM\Column(name: 'lastName', type: 'string', length: 250, nullable: true), + #[ORM\Column(name: 'lastName', type: 'string', length: 250, nullable: true), Serializer\Groups(['user_personal', 'human']), - Assert\Length(max: 250) - ] + Assert\Length(max: 250)] protected ?string $lastName = null; - #[ - ORM\Column(type: 'string', length: 250, nullable: true), + #[ORM\Column(type: 'string', length: 250, nullable: true), Serializer\Groups(['user_personal', 'human']), - Assert\Length(max: 250) - ] + Assert\Length(max: 250)] protected ?string $company = null; public function getEmail(): ?string diff --git a/lib/Models/src/Core/AbstractEntities/AbstractPositioned.php b/lib/Models/src/Core/AbstractEntities/AbstractPositioned.php index 179101c00..eba4b3bae 100644 --- a/lib/Models/src/Core/AbstractEntities/AbstractPositioned.php +++ b/lib/Models/src/Core/AbstractEntities/AbstractPositioned.php @@ -12,19 +12,15 @@ * * @deprecated since 2.6, use composition with PositionedTrait and PositionedInterface instead. */ -#[ - ORM\MappedSuperclass, +#[ORM\MappedSuperclass, ORM\HasLifecycleCallbacks, ORM\Table, - ORM\Index(columns: ['position']) -] + ORM\Index(columns: ['position'])] abstract class AbstractPositioned extends AbstractEntity implements PositionedInterface { use PositionedTrait; - #[ - ORM\Column(type: 'float'), - Serializer\Groups(['position']), - ] + #[ORM\Column(type: 'float'), + Serializer\Groups(['position']),] protected float $position = 0.0; } diff --git a/lib/Models/src/Core/AbstractEntities/DateTimedTrait.php b/lib/Models/src/Core/AbstractEntities/DateTimedTrait.php index 77094a1ef..bc5049432 100644 --- a/lib/Models/src/Core/AbstractEntities/DateTimedTrait.php +++ b/lib/Models/src/Core/AbstractEntities/DateTimedTrait.php @@ -9,16 +9,12 @@ trait DateTimedTrait { - #[ - ORM\Column(name: 'created_at', type: 'datetime', nullable: true), - Serializer\Groups(['timestamps']), - ] + #[ORM\Column(name: 'created_at', type: 'datetime', nullable: true), + Serializer\Groups(['timestamps']),] protected ?\DateTime $createdAt = null; - #[ - ORM\Column(name: 'updated_at', type: 'datetime', nullable: true), - Serializer\Groups(['timestamps']), - ] + #[ORM\Column(name: 'updated_at', type: 'datetime', nullable: true), + Serializer\Groups(['timestamps']),] protected ?\DateTime $updatedAt = null; public function getCreatedAt(): ?\DateTime diff --git a/lib/Models/src/Core/AbstractEntities/PositionedTrait.php b/lib/Models/src/Core/AbstractEntities/PositionedTrait.php index d3fc5ac4e..217de29d6 100644 --- a/lib/Models/src/Core/AbstractEntities/PositionedTrait.php +++ b/lib/Models/src/Core/AbstractEntities/PositionedTrait.php @@ -15,12 +15,10 @@ */ trait PositionedTrait { - #[ - ORM\Column(type: 'float'), + #[ORM\Column(type: 'float'), Serializer\Groups(['position']), ApiFilter(RangeFilter::class), - ApiFilter(NumericFilter::class) - ] + ApiFilter(NumericFilter::class)] protected float $position = 0.0; public function getPosition(): float diff --git a/lib/Models/src/Core/AbstractEntities/SequentialIdTrait.php b/lib/Models/src/Core/AbstractEntities/SequentialIdTrait.php index eda964c33..494961aa1 100644 --- a/lib/Models/src/Core/AbstractEntities/SequentialIdTrait.php +++ b/lib/Models/src/Core/AbstractEntities/SequentialIdTrait.php @@ -9,12 +9,10 @@ trait SequentialIdTrait { - #[ - ORM\Id, + #[ORM\Id, ORM\Column(type: 'integer'), ORM\GeneratedValue, - Serializer\Groups(['id']) - ] + Serializer\Groups(['id'])] protected ?int $id = null; public function getId(): ?int diff --git a/lib/Models/src/Utils/StringHandler.php b/lib/Models/src/Utils/StringHandler.php index 0999b8660..abcfab61c 100644 --- a/lib/Models/src/Utils/StringHandler.php +++ b/lib/Models/src/Utils/StringHandler.php @@ -145,9 +145,8 @@ public static function encodeWithSecret(?string $value, ?string $secret): string $secret = crypt($secret, $secret); return base64_encode($secret.base64_encode(strip_tags($value ?? ''))); - } else { - throw new \InvalidArgumentException('You cannot encode with an empty salt. Did you enter a secret security phrase in your conf/config.json file?', 1); } + throw new \InvalidArgumentException('You cannot encode with an empty salt. Did you enter a secret security phrase in your conf/config.json file?', 1); } /** @@ -169,9 +168,8 @@ public static function decodeWithSecret(?string $value, ?string $secret): string $nonSalted = str_replace($secret, '', $salted); return base64_decode($nonSalted); - } else { - throw new \InvalidArgumentException('You cannot encode with an empty salt. Did you enter a secret security phrase in your conf/config.json file?', 1); } + throw new \InvalidArgumentException('You cannot encode with an empty salt. Did you enter a secret security phrase in your conf/config.json file?', 1); } /** diff --git a/lib/OpenId/src/Authentication/OpenIdAuthenticator.php b/lib/OpenId/src/Authentication/OpenIdAuthenticator.php index 71caffbcd..75a63d82d 100644 --- a/lib/OpenId/src/Authentication/OpenIdAuthenticator.php +++ b/lib/OpenId/src/Authentication/OpenIdAuthenticator.php @@ -156,7 +156,7 @@ public function authenticate(Request $request): Passport $jwt = $configuration->parser()->parse($jsonResponse['id_token']); - if (!($jwt instanceof Plain)) { + if (!$jwt instanceof Plain) { throw new OpenIdAuthenticationException('JWT token must be instance of '.Plain::class); } diff --git a/lib/OpenId/src/Authentication/Provider/ChainJwtRoleStrategy.php b/lib/OpenId/src/Authentication/Provider/ChainJwtRoleStrategy.php index 155fefb72..d190d7d62 100644 --- a/lib/OpenId/src/Authentication/Provider/ChainJwtRoleStrategy.php +++ b/lib/OpenId/src/Authentication/Provider/ChainJwtRoleStrategy.php @@ -12,7 +12,7 @@ public function __construct(private array $strategies) { foreach ($this->strategies as $strategy) { - if (!($strategy instanceof JwtRoleStrategy)) { + if (!$strategy instanceof JwtRoleStrategy) { throw new \InvalidArgumentException('Strategy must implement '.JwtRoleStrategy::class); } } diff --git a/lib/OpenId/src/OpenIdJwtConfigurationFactory.php b/lib/OpenId/src/OpenIdJwtConfigurationFactory.php index 3657d9f1e..f7a3913ab 100644 --- a/lib/OpenId/src/OpenIdJwtConfigurationFactory.php +++ b/lib/OpenId/src/OpenIdJwtConfigurationFactory.php @@ -31,7 +31,7 @@ public function __construct( /** * @return Constraint[] */ - protected function getValidationConstraints(): array + private function getValidationConstraints(): array { $validators = [ new LooseValidAt(SystemClock::fromSystemTimezone()), diff --git a/lib/OpenId/src/User/OpenIdAccount.php b/lib/OpenId/src/User/OpenIdAccount.php index f76a0be75..dc5e58a07 100644 --- a/lib/OpenId/src/User/OpenIdAccount.php +++ b/lib/OpenId/src/User/OpenIdAccount.php @@ -62,7 +62,7 @@ public function __construct( #[Ignore] protected Token $jwtToken, ) { - if (!($this->jwtToken instanceof Token\Plain)) { + if (!$this->jwtToken instanceof Token\Plain) { throw new \InvalidArgumentException('Token must be an instance of '.Token\Plain::class); } /* @@ -126,7 +126,6 @@ public function getUsername(): string #[\Override] public function eraseCredentials(): void { - return; } public function getEmail(): ?string diff --git a/lib/RoadizCoreBundle/config/packages/roadiz_core.yaml b/lib/RoadizCoreBundle/config/packages/roadiz_core.yaml index c134c16e2..41a7cebfb 100644 --- a/lib/RoadizCoreBundle/config/packages/roadiz_core.yaml +++ b/lib/RoadizCoreBundle/config/packages/roadiz_core.yaml @@ -30,4 +30,3 @@ roadiz_core: domainName: '%env(string:VARNISH_DOMAIN)%' - diff --git a/lib/RoadizCoreBundle/src/Api/Extension/AttributeValueQueryExtension.php b/lib/RoadizCoreBundle/src/Api/Extension/AttributeValueQueryExtension.php index 2633666b2..acea74a67 100644 --- a/lib/RoadizCoreBundle/src/Api/Extension/AttributeValueQueryExtension.php +++ b/lib/RoadizCoreBundle/src/Api/Extension/AttributeValueQueryExtension.php @@ -79,7 +79,5 @@ private function apply( $queryBuilder ->andWhere($queryBuilder->expr()->eq($joinAlias.'.status', ':status')) ->setParameter(':status', NodeStatus::PUBLISHED); - - return; } } diff --git a/lib/RoadizCoreBundle/src/Api/Extension/NodeQueryExtension.php b/lib/RoadizCoreBundle/src/Api/Extension/NodeQueryExtension.php index 72e0a1ba6..b9b1fc04c 100644 --- a/lib/RoadizCoreBundle/src/Api/Extension/NodeQueryExtension.php +++ b/lib/RoadizCoreBundle/src/Api/Extension/NodeQueryExtension.php @@ -63,8 +63,6 @@ private function apply( ->andWhere($queryBuilder->expr()->eq('o.status', ':status')) ->setParameter(':lte_published_at', new \DateTime()) ->setParameter(':status', NodeStatus::PUBLISHED); - - return; } #[\Override] diff --git a/lib/RoadizCoreBundle/src/Api/Extension/NodesTagsQueryExtension.php b/lib/RoadizCoreBundle/src/Api/Extension/NodesTagsQueryExtension.php index ce6821416..7c657dff7 100644 --- a/lib/RoadizCoreBundle/src/Api/Extension/NodesTagsQueryExtension.php +++ b/lib/RoadizCoreBundle/src/Api/Extension/NodesTagsQueryExtension.php @@ -84,7 +84,5 @@ private function apply( $queryBuilder ->andWhere($queryBuilder->expr()->eq($existingNodeJoin->getAlias().'.status', ':status')) ->setParameter(':status', NodeStatus::PUBLISHED); - - return; } } diff --git a/lib/RoadizCoreBundle/src/Api/ListManager/SearchEnginePaginator.php b/lib/RoadizCoreBundle/src/Api/ListManager/SearchEnginePaginator.php index dd948126e..183f7ed95 100644 --- a/lib/RoadizCoreBundle/src/Api/ListManager/SearchEnginePaginator.php +++ b/lib/RoadizCoreBundle/src/Api/ListManager/SearchEnginePaginator.php @@ -16,7 +16,7 @@ public function __construct(private readonly SearchEngineListManager $listManage { } - protected function handleOnce(): void + private function handleOnce(): void { if (false === $this->handled) { $this->listManager->handle(); diff --git a/lib/RoadizCoreBundle/src/Api/TreeWalker/Definition/MultiTypeChildrenDefinition.php b/lib/RoadizCoreBundle/src/Api/TreeWalker/Definition/MultiTypeChildrenDefinition.php index 6d055c2b4..d3060a858 100644 --- a/lib/RoadizCoreBundle/src/Api/TreeWalker/Definition/MultiTypeChildrenDefinition.php +++ b/lib/RoadizCoreBundle/src/Api/TreeWalker/Definition/MultiTypeChildrenDefinition.php @@ -40,7 +40,7 @@ protected function getNodeTypes(NodeTypes $nodeTypesBag): array */ public function __invoke(NodesSources $source): array { - if (!($this->context instanceof NodeSourceWalkerContext)) { + if (!$this->context instanceof NodeSourceWalkerContext) { throw new \InvalidArgumentException('Context should be instance of '.NodeSourceWalkerContext::class); } diff --git a/lib/RoadizCoreBundle/src/Api/TreeWalker/Definition/NodeSourceDefinitionTrait.php b/lib/RoadizCoreBundle/src/Api/TreeWalker/Definition/NodeSourceDefinitionTrait.php index 246b891ab..eda850d35 100644 --- a/lib/RoadizCoreBundle/src/Api/TreeWalker/Definition/NodeSourceDefinitionTrait.php +++ b/lib/RoadizCoreBundle/src/Api/TreeWalker/Definition/NodeSourceDefinitionTrait.php @@ -23,7 +23,7 @@ protected function getQueryBuilder( NodesSources $parent, bool $onlyVisible = true, ): QueryBuilder { - if (!($this->context instanceof NodeSourceWalkerContext)) { + if (!$this->context instanceof NodeSourceWalkerContext) { throw new \InvalidArgumentException('Context should be instance of '.NodeSourceWalkerContext::class); } diff --git a/lib/RoadizCoreBundle/src/Api/TreeWalker/Definition/NonReachableNodeSourceBlockDefinition.php b/lib/RoadizCoreBundle/src/Api/TreeWalker/Definition/NonReachableNodeSourceBlockDefinition.php index 48667cafe..c717e4539 100644 --- a/lib/RoadizCoreBundle/src/Api/TreeWalker/Definition/NonReachableNodeSourceBlockDefinition.php +++ b/lib/RoadizCoreBundle/src/Api/TreeWalker/Definition/NonReachableNodeSourceBlockDefinition.php @@ -36,7 +36,7 @@ protected function getNodeTypes(NodeTypes $nodeTypesBag): array */ public function __invoke(NodesSources $source): array { - if (!($this->context instanceof NodeSourceWalkerContext)) { + if (!$this->context instanceof NodeSourceWalkerContext) { throw new \InvalidArgumentException('Context should be instance of '.NodeSourceWalkerContext::class); } diff --git a/lib/RoadizCoreBundle/src/Api/TreeWalker/Definition/ReachableNodeSourceDefinition.php b/lib/RoadizCoreBundle/src/Api/TreeWalker/Definition/ReachableNodeSourceDefinition.php index eb21964fd..ff2312e25 100644 --- a/lib/RoadizCoreBundle/src/Api/TreeWalker/Definition/ReachableNodeSourceDefinition.php +++ b/lib/RoadizCoreBundle/src/Api/TreeWalker/Definition/ReachableNodeSourceDefinition.php @@ -36,7 +36,7 @@ protected function getNodeTypes(NodeTypes $nodeTypesBag): array */ public function __invoke(NodesSources $source): array { - if (!($this->context instanceof NodeSourceWalkerContext)) { + if (!$this->context instanceof NodeSourceWalkerContext) { throw new \InvalidArgumentException('Context should be instance of '.NodeSourceWalkerContext::class); } diff --git a/lib/RoadizCoreBundle/src/Bag/DecoratedNodeTypes.php b/lib/RoadizCoreBundle/src/Bag/DecoratedNodeTypes.php index b6473e810..9e172653b 100644 --- a/lib/RoadizCoreBundle/src/Bag/DecoratedNodeTypes.php +++ b/lib/RoadizCoreBundle/src/Bag/DecoratedNodeTypes.php @@ -100,9 +100,9 @@ public function allSorted(?string $sort = 'ASC'): array usort($nodeTypes, function (NodeType $a, NodeType $b) use ($sort) { if ('DESC' !== $sort) { return strcmp($a->getName(), $b->getName()); - } else { - return strcmp($b->getName(), $a->getName()); } + + return strcmp($b->getName(), $a->getName()); }); return $nodeTypes; diff --git a/lib/RoadizCoreBundle/src/Cache/Clearer/OPCacheClearer.php b/lib/RoadizCoreBundle/src/Cache/Clearer/OPCacheClearer.php index 021f00c5c..e4fd847a1 100644 --- a/lib/RoadizCoreBundle/src/Cache/Clearer/OPCacheClearer.php +++ b/lib/RoadizCoreBundle/src/Cache/Clearer/OPCacheClearer.php @@ -6,7 +6,7 @@ final class OPCacheClearer implements ClearerInterface { - protected string $output; + private string $output; #[\Override] public function clear(): bool @@ -23,9 +23,8 @@ public function clear(): bool $this->output = 'PHP OPCache has been reset.'; return true; - } else { - $this->output = 'PHP OPCache is disabled.'; } + $this->output = 'PHP OPCache is disabled.'; return false; } diff --git a/lib/RoadizCoreBundle/src/Captcha/FriendlyCaptchaService.php b/lib/RoadizCoreBundle/src/Captcha/FriendlyCaptchaService.php index f7a07f2c2..deb930a10 100644 --- a/lib/RoadizCoreBundle/src/Captcha/FriendlyCaptchaService.php +++ b/lib/RoadizCoreBundle/src/Captcha/FriendlyCaptchaService.php @@ -14,10 +14,10 @@ { public function __construct( private HttpClientInterface $client, - protected ?string $publicKey, + private ?string $publicKey, #[\SensitiveParameter] - protected ?string $privateKey, - protected ?string $verifyUrl = 'https://global.frcapi.com/api/v2/captcha/siteverify', + private ?string $privateKey, + private ?string $verifyUrl = 'https://global.frcapi.com/api/v2/captcha/siteverify', ) { } diff --git a/lib/RoadizCoreBundle/src/Captcha/GoogleRecaptchaService.php b/lib/RoadizCoreBundle/src/Captcha/GoogleRecaptchaService.php index 3a99817b1..e5463012b 100644 --- a/lib/RoadizCoreBundle/src/Captcha/GoogleRecaptchaService.php +++ b/lib/RoadizCoreBundle/src/Captcha/GoogleRecaptchaService.php @@ -14,10 +14,10 @@ { public function __construct( private HttpClientInterface $client, - protected ?string $publicKey, + private ?string $publicKey, #[\SensitiveParameter] - protected ?string $privateKey, - protected ?string $verifyUrl = 'https://www.google.com/recaptcha/api/siteverify', + private ?string $privateKey, + private ?string $verifyUrl = 'https://www.google.com/recaptcha/api/siteverify', ) { } diff --git a/lib/RoadizCoreBundle/src/Captcha/HCaptchaService.php b/lib/RoadizCoreBundle/src/Captcha/HCaptchaService.php index a43a075d8..86cc6b6c4 100644 --- a/lib/RoadizCoreBundle/src/Captcha/HCaptchaService.php +++ b/lib/RoadizCoreBundle/src/Captcha/HCaptchaService.php @@ -14,10 +14,10 @@ { public function __construct( private HttpClientInterface $client, - protected ?string $publicKey, + private ?string $publicKey, #[\SensitiveParameter] - protected ?string $privateKey, - protected ?string $verifyUrl = 'https://api.hcaptcha.com/siteverify', + private ?string $privateKey, + private ?string $verifyUrl = 'https://api.hcaptcha.com/siteverify', ) { } diff --git a/lib/RoadizCoreBundle/src/Captcha/TurnstileCaptchaService.php b/lib/RoadizCoreBundle/src/Captcha/TurnstileCaptchaService.php index 230bf8721..1e06e36ac 100644 --- a/lib/RoadizCoreBundle/src/Captcha/TurnstileCaptchaService.php +++ b/lib/RoadizCoreBundle/src/Captcha/TurnstileCaptchaService.php @@ -14,10 +14,10 @@ { public function __construct( private HttpClientInterface $client, - protected ?string $publicKey, + private ?string $publicKey, #[\SensitiveParameter] - protected ?string $privateKey, - protected ?string $verifyUrl = 'https://challenges.cloudflare.com/turnstile/v0/siteverify', + private ?string $privateKey, + private ?string $verifyUrl = 'https://challenges.cloudflare.com/turnstile/v0/siteverify', ) { } diff --git a/lib/RoadizCoreBundle/src/Console/GetCronLastExecDateCommand.php b/lib/RoadizCoreBundle/src/Console/GetCronLastExecDateCommand.php index 8b98ea98c..a9c55a16a 100644 --- a/lib/RoadizCoreBundle/src/Console/GetCronLastExecDateCommand.php +++ b/lib/RoadizCoreBundle/src/Console/GetCronLastExecDateCommand.php @@ -31,7 +31,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $io = new SymfonyStyle($input, $output); $setting = $this->settingRepository->findOneByName('cron_last_exec_date'); - if (!($setting instanceof Setting)) { + if (!$setting instanceof Setting) { $io->warning('Last execution date of cron job has not been persisted yet.'); return Command::FAILURE; diff --git a/lib/RoadizCoreBundle/src/Console/UsersCommand.php b/lib/RoadizCoreBundle/src/Console/UsersCommand.php index 947816c99..c7b213303 100644 --- a/lib/RoadizCoreBundle/src/Console/UsersCommand.php +++ b/lib/RoadizCoreBundle/src/Console/UsersCommand.php @@ -106,7 +106,7 @@ protected function getUserForInput(InputInterface $input): User ->getRepository(User::class) ->findOneBy(['username' => $name]); - if (!($user instanceof User)) { + if (!$user instanceof User) { throw new InvalidArgumentException('User “'.$name.'” does not exist.'); } diff --git a/lib/RoadizCoreBundle/src/Console/UsersDeleteCommand.php b/lib/RoadizCoreBundle/src/Console/UsersDeleteCommand.php index cc3eb497d..569bc96d3 100644 --- a/lib/RoadizCoreBundle/src/Console/UsersDeleteCommand.php +++ b/lib/RoadizCoreBundle/src/Console/UsersDeleteCommand.php @@ -46,10 +46,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int $io->success('User “'.$name.'” deleted.'); return 0; - } else { - $io->warning('User “'.$name.'” was not deleted.'); - - return 1; } + $io->warning('User “'.$name.'” was not deleted.'); + + return 1; } } diff --git a/lib/RoadizCoreBundle/src/Console/UsersDisableCommand.php b/lib/RoadizCoreBundle/src/Console/UsersDisableCommand.php index af5645eb3..d4f959946 100644 --- a/lib/RoadizCoreBundle/src/Console/UsersDisableCommand.php +++ b/lib/RoadizCoreBundle/src/Console/UsersDisableCommand.php @@ -46,10 +46,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int $io->success('User “'.$name.'” disabled.'); return 0; - } else { - $io->warning('User “'.$name.'” was not disabled.'); - - return 1; } + $io->warning('User “'.$name.'” was not disabled.'); + + return 1; } } diff --git a/lib/RoadizCoreBundle/src/Console/UsersEnableCommand.php b/lib/RoadizCoreBundle/src/Console/UsersEnableCommand.php index f779d6cfe..09a35659e 100644 --- a/lib/RoadizCoreBundle/src/Console/UsersEnableCommand.php +++ b/lib/RoadizCoreBundle/src/Console/UsersEnableCommand.php @@ -46,10 +46,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int $io->success('User “'.$name.'” was enabled.'); return 0; - } else { - $io->warning('User “'.$name.'” was not enabled'); - - return 1; } + $io->warning('User “'.$name.'” was not enabled'); + + return 1; } } diff --git a/lib/RoadizCoreBundle/src/Console/UsersExpireCommand.php b/lib/RoadizCoreBundle/src/Console/UsersExpireCommand.php index cba48cb83..cbf90b5a8 100644 --- a/lib/RoadizCoreBundle/src/Console/UsersExpireCommand.php +++ b/lib/RoadizCoreBundle/src/Console/UsersExpireCommand.php @@ -54,10 +54,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int $io->success('User “'.$name.'” expiration date was set on '.$expirationDate->format('c').'.'); return 0; - } else { - $io->warning('User “'.$name.'” was not updated.'); - - return 1; } + $io->warning('User “'.$name.'” was not updated.'); + + return 1; } } diff --git a/lib/RoadizCoreBundle/src/Console/UsersLockCommand.php b/lib/RoadizCoreBundle/src/Console/UsersLockCommand.php index 541fe2692..a4220bae5 100644 --- a/lib/RoadizCoreBundle/src/Console/UsersLockCommand.php +++ b/lib/RoadizCoreBundle/src/Console/UsersLockCommand.php @@ -46,10 +46,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int $io->success('User “'.$name.'” locked.'); return 0; - } else { - $io->warning('User “'.$name.'” was not locked.'); - - return 1; } + $io->warning('User “'.$name.'” was not locked.'); + + return 1; } } diff --git a/lib/RoadizCoreBundle/src/Console/UsersPasswordCommand.php b/lib/RoadizCoreBundle/src/Console/UsersPasswordCommand.php index 3bb99ca49..667571368 100644 --- a/lib/RoadizCoreBundle/src/Console/UsersPasswordCommand.php +++ b/lib/RoadizCoreBundle/src/Console/UsersPasswordCommand.php @@ -75,10 +75,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int $io->success('A new password was regenerated for '.$name.': '.$user->getPlainPassword()); return 0; - } else { - $io->warning('User password was not changed.'); - - return 1; } + $io->warning('User password was not changed.'); + + return 1; } } diff --git a/lib/RoadizCoreBundle/src/Console/UsersUnexpireCommand.php b/lib/RoadizCoreBundle/src/Console/UsersUnexpireCommand.php index 87625d5c2..513e004f7 100644 --- a/lib/RoadizCoreBundle/src/Console/UsersUnexpireCommand.php +++ b/lib/RoadizCoreBundle/src/Console/UsersUnexpireCommand.php @@ -46,10 +46,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int $io->success('User “'.$name.'” unexpired.'); return 0; - } else { - $io->warning('User “'.$name.'” was not updated.'); - - return 1; } + $io->warning('User “'.$name.'” was not updated.'); + + return 1; } } diff --git a/lib/RoadizCoreBundle/src/Console/UsersUnlockCommand.php b/lib/RoadizCoreBundle/src/Console/UsersUnlockCommand.php index 6c7e22488..29f7aada5 100644 --- a/lib/RoadizCoreBundle/src/Console/UsersUnlockCommand.php +++ b/lib/RoadizCoreBundle/src/Console/UsersUnlockCommand.php @@ -46,10 +46,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int $io->success('User “'.$name.'” unlocked.'); return 0; - } else { - $io->warning('User “'.$name.'” was not unlocked.'); - - return 1; } + $io->warning('User “'.$name.'” was not unlocked.'); + + return 1; } } diff --git a/lib/RoadizCoreBundle/src/Controller/CustomFormController.php b/lib/RoadizCoreBundle/src/Controller/CustomFormController.php index 6c57dcc7a..f73c5ad81 100644 --- a/lib/RoadizCoreBundle/src/Controller/CustomFormController.php +++ b/lib/RoadizCoreBundle/src/Controller/CustomFormController.php @@ -148,9 +148,9 @@ public function addAction(Request $request, int $customFormId): Response if ($mixed instanceof Response) { return $mixed; - } else { - return $this->render('@RoadizCore/customForm/customForm.html.twig', $mixed); } + + return $this->render('@RoadizCore/customForm/customForm.html.twig', $mixed); } public function sentAction(Request $request, int $customFormId): Response diff --git a/lib/RoadizCoreBundle/src/CustomForm/CustomFormHelper.php b/lib/RoadizCoreBundle/src/CustomForm/CustomFormHelper.php index db300261f..f71a6645d 100644 --- a/lib/RoadizCoreBundle/src/CustomForm/CustomFormHelper.php +++ b/lib/RoadizCoreBundle/src/CustomForm/CustomFormHelper.php @@ -152,7 +152,7 @@ public function parseAnswerFormData( * @throws FilesystemException * @throws \Exception */ - protected function handleUploadedFile( + private function handleUploadedFile( UploadedFile $file, CustomFormFieldAttribute $fieldAttr, ): ?DocumentInterface { @@ -167,7 +167,7 @@ protected function handleUploadedFile( return $document; } - protected function getDocumentFolderForCustomForm(): ?Folder + private function getDocumentFolderForCustomForm(): ?Folder { return $this->em->getRepository(Folder::class) ->findOrCreateByPath( @@ -187,9 +187,9 @@ private function formValueToString(mixed $rawValue): string $values = array_map('strip_tags', $values); return implode(static::ARRAY_SEPARATOR, $values); - } else { - return strip_tags((string) $rawValue); } + + return strip_tags((string) $rawValue); } private function getAttribute(CustomFormAnswer $answer, CustomFormField $field): ?CustomFormFieldAttribute diff --git a/lib/RoadizCoreBundle/src/CustomForm/Message/Handler/CustomFormAnswerNotifyMessageHandler.php b/lib/RoadizCoreBundle/src/CustomForm/Message/Handler/CustomFormAnswerNotifyMessageHandler.php index a4d99e15b..233fc26ac 100644 --- a/lib/RoadizCoreBundle/src/CustomForm/Message/Handler/CustomFormAnswerNotifyMessageHandler.php +++ b/lib/RoadizCoreBundle/src/CustomForm/Message/Handler/CustomFormAnswerNotifyMessageHandler.php @@ -36,7 +36,7 @@ public function __invoke(CustomFormAnswerNotifyMessage $message): void { $answer = $this->customFormAnswerRepository->find($message->getCustomFormAnswerId()); - if (!($answer instanceof CustomFormAnswer)) { + if (!$answer instanceof CustomFormAnswer) { throw new UnrecoverableMessageHandlingException('CustomFormAnswer not found'); } diff --git a/lib/RoadizCoreBundle/src/DependencyInjection/Configuration.php b/lib/RoadizCoreBundle/src/DependencyInjection/Configuration.php index 74940dd96..d18e36fce 100644 --- a/lib/RoadizCoreBundle/src/DependencyInjection/Configuration.php +++ b/lib/RoadizCoreBundle/src/DependencyInjection/Configuration.php @@ -216,6 +216,20 @@ protected function addSolrNode() $node->children() ->scalarNode('timeout')->defaultValue(3)->end() + ->arrayNode('search') + ->addDefaultsIfNotSet() + ->children() + ->integerNode('fuzzy_proximity') + ->defaultValue(2) + ->min(0) + ->max(2) + ->end() + ->integerNode('fuzzy_min_term_length') + ->defaultValue(3) + ->min(0) + ->end() + ->end() + ->end() ->arrayNode('endpoints') ->defaultValue([]) ->useAttributeAsKey('name') diff --git a/lib/RoadizCoreBundle/src/DependencyInjection/RoadizCoreExtension.php b/lib/RoadizCoreBundle/src/DependencyInjection/RoadizCoreExtension.php index e39049988..4b21b019b 100644 --- a/lib/RoadizCoreBundle/src/DependencyInjection/RoadizCoreExtension.php +++ b/lib/RoadizCoreBundle/src/DependencyInjection/RoadizCoreExtension.php @@ -72,7 +72,6 @@ public function load(array $configs, ContainerBuilder $container): void $container->setParameter('roadiz_core.preview_required_role_name', $config['previewRequiredRoleName']); $container->setParameter('roadiz_core.force_locale', $config['forceLocale']); $container->setParameter('roadiz_core.force_locale_with_url_aliases', $config['forceLocaleWithUrlAliases']); - /* * Assets config */ diff --git a/lib/RoadizCoreBundle/src/Doctrine/EventSubscriber/UserLifeCycleSubscriber.php b/lib/RoadizCoreBundle/src/Doctrine/EventSubscriber/UserLifeCycleSubscriber.php index e89334690..2d148d071 100644 --- a/lib/RoadizCoreBundle/src/Doctrine/EventSubscriber/UserLifeCycleSubscriber.php +++ b/lib/RoadizCoreBundle/src/Doctrine/EventSubscriber/UserLifeCycleSubscriber.php @@ -76,7 +76,7 @@ public function preUpdate(PreUpdateEventArgs $event): void /** * @return bool returns true if password has been updated, false otherwise */ - protected function setPassword(User $user, ?string $plainPassword): bool + private function setPassword(User $user, ?string $plainPassword): bool { if (null === $plainPassword) { return false; diff --git a/lib/RoadizCoreBundle/src/Doctrine/ORM/Filter/NodesSourcesNodeTypeFilter.php b/lib/RoadizCoreBundle/src/Doctrine/ORM/Filter/NodesSourcesNodeTypeFilter.php index 99080b364..2565ff699 100644 --- a/lib/RoadizCoreBundle/src/Doctrine/ORM/Filter/NodesSourcesNodeTypeFilter.php +++ b/lib/RoadizCoreBundle/src/Doctrine/ORM/Filter/NodesSourcesNodeTypeFilter.php @@ -22,7 +22,7 @@ public static function getSubscribedEvents(): array ]; } - protected function supports(FilterNodesSourcesQueryBuilderCriteriaEvent $event): bool + private function supports(FilterNodesSourcesQueryBuilderCriteriaEvent $event): bool { return $event->supports() && 'node.nodeType' === $event->getProperty() diff --git a/lib/RoadizCoreBundle/src/Doctrine/ORM/Filter/NodesSourcesReachableFilter.php b/lib/RoadizCoreBundle/src/Doctrine/ORM/Filter/NodesSourcesReachableFilter.php index 1f5322d65..7ff0033ba 100644 --- a/lib/RoadizCoreBundle/src/Doctrine/ORM/Filter/NodesSourcesReachableFilter.php +++ b/lib/RoadizCoreBundle/src/Doctrine/ORM/Filter/NodesSourcesReachableFilter.php @@ -34,7 +34,7 @@ public static function getSubscribedEvents(): array ]; } - protected function supports(FilterNodesSourcesQueryBuilderCriteriaEvent $event): bool + private function supports(FilterNodesSourcesQueryBuilderCriteriaEvent $event): bool { return $event->supports() && in_array($event->getProperty(), self::PARAMETER) diff --git a/lib/RoadizCoreBundle/src/Document/MessageHandler/DocumentExifMessageHandler.php b/lib/RoadizCoreBundle/src/Document/MessageHandler/DocumentExifMessageHandler.php index 218c92601..0cf4e5b12 100644 --- a/lib/RoadizCoreBundle/src/Document/MessageHandler/DocumentExifMessageHandler.php +++ b/lib/RoadizCoreBundle/src/Document/MessageHandler/DocumentExifMessageHandler.php @@ -108,11 +108,10 @@ private function getDescription(array $exif): ?string } return $comment; - } else { - foreach ($section as $skey => $value) { - if ('comment' == \mb_strtolower($skey)) { - return $value; - } + } + foreach ($section as $skey => $value) { + if ('comment' == \mb_strtolower($skey)) { + return $value; } } } diff --git a/lib/RoadizCoreBundle/src/Entity/AbstractDateTimedPositioned.php b/lib/RoadizCoreBundle/src/Entity/AbstractDateTimedPositioned.php index 39ac2c392..6c9d938d0 100644 --- a/lib/RoadizCoreBundle/src/Entity/AbstractDateTimedPositioned.php +++ b/lib/RoadizCoreBundle/src/Entity/AbstractDateTimedPositioned.php @@ -17,14 +17,12 @@ * * @deprecated Use composition instead, use PositionedTrait and DateTimedTrait */ -#[ - ORM\MappedSuperclass, +#[ORM\MappedSuperclass, ORM\HasLifecycleCallbacks, ORM\Table, ORM\Index(columns: ['position']), ORM\Index(columns: ['created_at']), - ORM\Index(columns: ['updated_at']) -] + ORM\Index(columns: ['updated_at'])] abstract class AbstractDateTimedPositioned implements PositionedInterface, DateTimedInterface, PersistableInterface { use SequentialIdTrait; diff --git a/lib/RoadizCoreBundle/src/Entity/AbstractField.php b/lib/RoadizCoreBundle/src/Entity/AbstractField.php index 39b306b2c..c4bb2b212 100644 --- a/lib/RoadizCoreBundle/src/Entity/AbstractField.php +++ b/lib/RoadizCoreBundle/src/Entity/AbstractField.php @@ -16,90 +16,70 @@ use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Yaml\Yaml; -#[ - ORM\MappedSuperclass, +#[ORM\MappedSuperclass, ORM\Table, ORM\HasLifecycleCallbacks, ORM\Index(columns: ['position']), ORM\Index(columns: ['group_name']), - ORM\Index(columns: ['group_name_canonical']) -] + ORM\Index(columns: ['group_name_canonical'])] abstract class AbstractField implements PositionedInterface, PersistableInterface { use SequentialIdTrait; use PositionedTrait; use FieldTypeTrait; - #[ - ORM\Column(name: 'group_name', type: 'string', length: 250, nullable: true), + #[ORM\Column(name: 'group_name', type: 'string', length: 250, nullable: true), Assert\Length(max: 250), - Serializer\Groups(['node_type', 'node_type:import', 'setting']), - ] + Serializer\Groups(['node_type', 'node_type:import', 'setting']),] protected ?string $groupName = null; - #[ - ORM\Column(name: 'group_name_canonical', type: 'string', length: 250, nullable: true), + #[ORM\Column(name: 'group_name_canonical', type: 'string', length: 250, nullable: true), Serializer\Groups(['node_type', 'setting']), - Assert\Length(max: 250), - ] + Assert\Length(max: 250),] protected ?string $groupNameCanonical = null; - #[ - ORM\Column(type: 'string', length: 250), + #[ORM\Column(type: 'string', length: 250), Serializer\Groups(['node_type', 'node_type:import', 'setting']), Assert\Length(max: 250), Assert\NotBlank(), - Assert\NotNull() - ] + Assert\NotNull()] protected string $name; - #[ - ORM\Column(type: 'string', length: 250), + #[ORM\Column(type: 'string', length: 250), Serializer\Groups(['node_type', 'node_type:import', 'setting']), Assert\Length(max: 250), Assert\NotBlank(), - Assert\NotNull() - ] + Assert\NotNull()] // @phpstan-ignore-next-line protected ?string $label = null; - #[ - ORM\Column(type: 'string', length: 250, nullable: true), + #[ORM\Column(type: 'string', length: 250, nullable: true), Serializer\Groups(['node_type', 'node_type:import', 'setting']), - Assert\Length(max: 250), - ] + Assert\Length(max: 250),] protected ?string $placeholder = null; - #[ - ORM\Column(type: 'text', nullable: true), - Serializer\Groups(['node_type', 'node_type:import', 'setting']), - ] + #[ORM\Column(type: 'text', nullable: true), + Serializer\Groups(['node_type', 'node_type:import', 'setting']),] protected ?string $description = null; - #[ - ORM\Column(name: 'default_values', type: 'text', nullable: true), - Serializer\Groups(['node_type', 'setting']), - ] + #[ORM\Column(name: 'default_values', type: 'text', nullable: true), + Serializer\Groups(['node_type', 'setting']),] protected ?string $defaultValues = null; - #[ - ORM\Column( - type: Types::SMALLINT, - nullable: false, - enumType: FieldType::class, - options: ['default' => FieldType::STRING_T] - ), - Serializer\Groups(['node_type', 'setting']), - ] + #[ORM\Column( + type: Types::SMALLINT, + nullable: false, + enumType: FieldType::class, + options: ['default' => FieldType::STRING_T] + ), + Serializer\Groups(['node_type', 'setting']),] protected FieldType $type = FieldType::STRING_T; /** * If current field data should be expanded (for choices and country types). */ - #[ - ORM\Column(name: 'expanded', type: 'boolean', nullable: false, options: ['default' => false]), - Serializer\Groups(['node_type', 'node_type:import', 'setting']), - ] + #[ORM\Column(name: 'expanded', type: 'boolean', nullable: false, options: ['default' => false]), + Serializer\Groups(['node_type', 'node_type:import', 'setting']),] protected bool $expanded = false; public function __construct() diff --git a/lib/RoadizCoreBundle/src/Entity/Attribute.php b/lib/RoadizCoreBundle/src/Entity/Attribute.php index 19304b12c..ec6ea25dd 100644 --- a/lib/RoadizCoreBundle/src/Entity/Attribute.php +++ b/lib/RoadizCoreBundle/src/Entity/Attribute.php @@ -19,8 +19,7 @@ use Symfony\Component\Validator\Constraints\NotNull; use Symfony\Component\Validator\Constraints\Range; -#[ - ORM\Entity(repositoryClass: AttributeRepository::class), +#[ORM\Entity(repositoryClass: AttributeRepository::class), ORM\Table(name: 'attributes'), ORM\Index(columns: ['code']), ORM\Index(columns: ['type']), @@ -29,8 +28,7 @@ ORM\Index(columns: ['color']), ORM\Index(columns: ['group_id']), ORM\HasLifecycleCallbacks, - UniqueEntity(fields: ['code']), -] + UniqueEntity(fields: ['code']),] class Attribute implements AttributeInterface { use SequentialIdTrait; @@ -39,16 +37,14 @@ class Attribute implements AttributeInterface /** * @var Collection */ - #[ - ORM\OneToMany( - mappedBy: 'attribute', - targetEntity: AttributeDocuments::class, - cascade: ['persist', 'merge'], - orphanRemoval: true - ), + #[ORM\OneToMany( + mappedBy: 'attribute', + targetEntity: AttributeDocuments::class, + cascade: ['persist', 'merge'], + orphanRemoval: true + ), ORM\OrderBy(['position' => 'ASC']), - SymfonySerializer\Ignore - ] + SymfonySerializer\Ignore] protected Collection $attributeDocuments; #[ORM\ManyToOne(targetEntity: Realm::class)] @@ -65,13 +61,11 @@ class Attribute implements AttributeInterface /** * @var int absolute weight for sorting attributes in filtered lists */ - #[ - ORM\Column(type: 'integer', nullable: false, options: ['default' => 0]), + #[ORM\Column(type: 'integer', nullable: false, options: ['default' => 0]), SymfonySerializer\Groups(['attribute', 'attribute:export', 'attribute:import', 'node', 'nodes_sources']), ApiFilter(OrderFilter::class), Range(min: 0, max: 9999), - NotNull, - ] + NotNull,] protected int $weight = 0; public function __construct() diff --git a/lib/RoadizCoreBundle/src/Entity/AttributeDocuments.php b/lib/RoadizCoreBundle/src/Entity/AttributeDocuments.php index 9ebed6070..1720b38f3 100644 --- a/lib/RoadizCoreBundle/src/Entity/AttributeDocuments.php +++ b/lib/RoadizCoreBundle/src/Entity/AttributeDocuments.php @@ -16,50 +16,44 @@ * Describes a complex ManyToMany relation * between Attribute and Documents. */ -#[ - ORM\Entity(repositoryClass: AttributeDocumentsRepository::class), +#[ORM\Entity(repositoryClass: AttributeDocumentsRepository::class), ORM\Table(name: 'attributes_documents'), ORM\HasLifecycleCallbacks, ORM\Index(columns: ['position']), - ORM\Index(columns: ['attribute_id', 'position']) -] + ORM\Index(columns: ['attribute_id', 'position'])] class AttributeDocuments implements PositionedInterface, PersistableInterface { use SequentialIdTrait; use PositionedTrait; public function __construct( - #[ - ORM\ManyToOne( - targetEntity: Attribute::class, - cascade: ['persist', 'merge'], - fetch: 'EAGER', - inversedBy: 'attributeDocuments' - ), + #[ORM\ManyToOne( + targetEntity: Attribute::class, + cascade: ['persist', 'merge'], + fetch: 'EAGER', + inversedBy: 'attributeDocuments' + ), ORM\JoinColumn( name: 'attribute_id', referencedColumnName: 'id', nullable: false, onDelete: 'CASCADE' ), - SymfonySerializer\Ignore() - ] + SymfonySerializer\Ignore()] protected Attribute $attribute, - #[ - ORM\ManyToOne( - targetEntity: Document::class, - cascade: ['persist', 'merge'], - fetch: 'EAGER', - inversedBy: 'attributeDocuments' - ), + #[ORM\ManyToOne( + targetEntity: Document::class, + cascade: ['persist', 'merge'], + fetch: 'EAGER', + inversedBy: 'attributeDocuments' + ), ORM\JoinColumn( name: 'document_id', referencedColumnName: 'id', nullable: false, onDelete: 'CASCADE' ), - SymfonySerializer\Groups(['attribute']), - ] + SymfonySerializer\Groups(['attribute']),] protected Document $document, ) { } diff --git a/lib/RoadizCoreBundle/src/Entity/AttributeGroup.php b/lib/RoadizCoreBundle/src/Entity/AttributeGroup.php index 654d49347..affa84b4a 100644 --- a/lib/RoadizCoreBundle/src/Entity/AttributeGroup.php +++ b/lib/RoadizCoreBundle/src/Entity/AttributeGroup.php @@ -13,13 +13,11 @@ use RZ\Roadiz\CoreBundle\Repository\AttributeGroupRepository; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; -#[ - ORM\Entity(repositoryClass: AttributeGroupRepository::class), +#[ORM\Entity(repositoryClass: AttributeGroupRepository::class), ORM\Table(name: 'attribute_groups'), ORM\Index(columns: ['canonical_name']), ORM\HasLifecycleCallbacks, - UniqueEntity(fields: ['canonicalName']) -] + UniqueEntity(fields: ['canonicalName'])] class AttributeGroup implements AttributeGroupInterface { use SequentialIdTrait; diff --git a/lib/RoadizCoreBundle/src/Entity/AttributeGroupTranslation.php b/lib/RoadizCoreBundle/src/Entity/AttributeGroupTranslation.php index aba464e36..0cc4991a2 100644 --- a/lib/RoadizCoreBundle/src/Entity/AttributeGroupTranslation.php +++ b/lib/RoadizCoreBundle/src/Entity/AttributeGroupTranslation.php @@ -11,16 +11,14 @@ use RZ\Roadiz\CoreBundle\Repository\AttributeGroupTranslationRepository; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; -#[ - ORM\Entity(repositoryClass: AttributeGroupTranslationRepository::class), +#[ORM\Entity(repositoryClass: AttributeGroupTranslationRepository::class), ORM\Table(name: 'attribute_group_translations'), ORM\Index(columns: ['name']), ORM\UniqueConstraint(columns: ['attribute_group_id', 'translation_id']), ORM\UniqueConstraint(columns: ['name', 'translation_id']), ORM\HasLifecycleCallbacks, UniqueEntity(fields: ['attributeGroup', 'translation']), - UniqueEntity(fields: ['name', 'translation']) -] + UniqueEntity(fields: ['name', 'translation'])] class AttributeGroupTranslation implements AttributeGroupTranslationInterface { use SequentialIdTrait; diff --git a/lib/RoadizCoreBundle/src/Entity/AttributeTranslation.php b/lib/RoadizCoreBundle/src/Entity/AttributeTranslation.php index 89b2e3d99..033837b79 100644 --- a/lib/RoadizCoreBundle/src/Entity/AttributeTranslation.php +++ b/lib/RoadizCoreBundle/src/Entity/AttributeTranslation.php @@ -11,14 +11,12 @@ use RZ\Roadiz\CoreBundle\Repository\AttributeTranslationRepository; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; -#[ - ORM\Entity(repositoryClass: AttributeTranslationRepository::class), +#[ORM\Entity(repositoryClass: AttributeTranslationRepository::class), ORM\Table(name: 'attribute_translations'), ORM\Index(columns: ['label']), ORM\UniqueConstraint(columns: ['attribute_id', 'translation_id']), ORM\HasLifecycleCallbacks, - UniqueEntity(fields: ['attribute', 'translation'], errorPath: 'translation') -] + UniqueEntity(fields: ['attribute', 'translation'], errorPath: 'translation')] class AttributeTranslation implements AttributeTranslationInterface { use SequentialIdTrait; diff --git a/lib/RoadizCoreBundle/src/Entity/AttributeValue.php b/lib/RoadizCoreBundle/src/Entity/AttributeValue.php index 64d02ff33..d94e7d2f6 100644 --- a/lib/RoadizCoreBundle/src/Entity/AttributeValue.php +++ b/lib/RoadizCoreBundle/src/Entity/AttributeValue.php @@ -19,8 +19,7 @@ use RZ\Roadiz\CoreBundle\Repository\AttributeValueRepository; use Symfony\Component\Serializer\Attribute as SymfonySerializer; -#[ - ORM\Entity(repositoryClass: AttributeValueRepository::class), +#[ORM\Entity(repositoryClass: AttributeValueRepository::class), ORM\Table(name: 'attribute_values'), ORM\Index(columns: ['attribute_id', 'node_id']), ORM\Index(columns: ['node_id', 'position'], name: 'idx_attribute_value_node_position'), @@ -29,16 +28,14 @@ ApiFilter(PropertyFilter::class), ApiFilter(BaseFilter\OrderFilter::class, properties: [ 'position', - ]), -] + ]),] class AttributeValue implements AttributeValueInterface { use SequentialIdTrait; use PositionedTrait; use AttributeValueTrait; - #[ - ORM\ManyToOne(targetEntity: Node::class, inversedBy: 'attributeValues'), + #[ORM\ManyToOne(targetEntity: Node::class, inversedBy: 'attributeValues'), ORM\JoinColumn(name: 'node_id', referencedColumnName: 'id', nullable: false, onDelete: 'CASCADE'), SymfonySerializer\Groups(['attribute_node']), SymfonySerializer\MaxDepth(1), @@ -50,8 +47,7 @@ class AttributeValue implements AttributeValueInterface ]), ApiFilter(BaseFilter\BooleanFilter::class, properties: [ 'node.visible', - ]) - ] + ])] protected Node $node; #[ORM\ManyToOne(targetEntity: Realm::class)] diff --git a/lib/RoadizCoreBundle/src/Entity/AttributeValueTranslation.php b/lib/RoadizCoreBundle/src/Entity/AttributeValueTranslation.php index b0a350072..12de93d4c 100644 --- a/lib/RoadizCoreBundle/src/Entity/AttributeValueTranslation.php +++ b/lib/RoadizCoreBundle/src/Entity/AttributeValueTranslation.php @@ -10,13 +10,11 @@ use RZ\Roadiz\CoreBundle\Model\AttributeValueTranslationTrait; use RZ\Roadiz\CoreBundle\Repository\AttributeValueTranslationRepository; -#[ - ORM\Entity(repositoryClass: AttributeValueTranslationRepository::class), +#[ORM\Entity(repositoryClass: AttributeValueTranslationRepository::class), ORM\Table(name: 'attribute_value_translations'), ORM\Index(columns: ['value']), ORM\Index(columns: ['translation_id', 'attribute_value']), - ORM\HasLifecycleCallbacks -] + ORM\HasLifecycleCallbacks] class AttributeValueTranslation implements AttributeValueTranslationInterface { use SequentialIdTrait; diff --git a/lib/RoadizCoreBundle/src/Entity/CustomForm.php b/lib/RoadizCoreBundle/src/Entity/CustomForm.php index bf1699d0c..bb69036ad 100644 --- a/lib/RoadizCoreBundle/src/Entity/CustomForm.php +++ b/lib/RoadizCoreBundle/src/Entity/CustomForm.php @@ -23,113 +23,89 @@ * CustomForms describe each node structure family, * They are mandatory before creating any Node. */ -#[ - ORM\Entity(repositoryClass: CustomFormRepository::class), +#[ORM\Entity(repositoryClass: CustomFormRepository::class), ORM\Table(name: 'custom_forms'), ORM\HasLifecycleCallbacks, UniqueEntity(fields: ['name']), ORM\Index(columns: ['created_at'], name: 'custom_form_created_at'), - ORM\Index(columns: ['updated_at'], name: 'custom_form_updated_at'), -] + ORM\Index(columns: ['updated_at'], name: 'custom_form_updated_at'),] class CustomForm implements DateTimedInterface, PersistableInterface { use SequentialIdTrait; use DateTimedTrait; - #[ - ORM\Column(name: 'color', type: 'string', length: 7, unique: false, nullable: true), + #[ORM\Column(name: 'color', type: 'string', length: 7, unique: false, nullable: true), Assert\Length(max: 7), - SymfonySerializer\Groups(['custom_form', 'nodes_sources']), - ] + SymfonySerializer\Groups(['custom_form', 'nodes_sources']),] protected ?string $color = '#000000'; - #[ - ORM\Column(type: 'string', length: 250, unique: true), + #[ORM\Column(type: 'string', length: 250, unique: true), SymfonySerializer\Groups(['custom_form', 'nodes_sources']), Assert\NotNull(), Assert\NotBlank(), - Assert\Length(max: 250), - ] + Assert\Length(max: 250),] private string $name = 'Untitled'; - #[ - ORM\Column(name: 'display_name', type: 'string', length: 250), + #[ORM\Column(name: 'display_name', type: 'string', length: 250), SymfonySerializer\Groups(['custom_form', 'nodes_sources']), Assert\NotNull(), Assert\NotBlank(), - Assert\Length(max: 250), - ] + Assert\Length(max: 250),] private string $displayName = 'Untitled'; - #[ - ORM\Column(type: 'text', nullable: true), - SymfonySerializer\Groups(['custom_form', 'nodes_sources']), - ] + #[ORM\Column(type: 'text', nullable: true), + SymfonySerializer\Groups(['custom_form', 'nodes_sources']),] private ?string $description = null; - #[ - ORM\Column(type: 'text', nullable: true), + #[ORM\Column(type: 'text', nullable: true), SymfonySerializer\Groups(['custom_form:export']), - Assert\NotBlank(), - ] + Assert\NotBlank(),] private ?string $email = null; - #[ - ORM\Column(type: 'string', length: 15, nullable: true), + #[ORM\Column(type: 'string', length: 15, nullable: true), SymfonySerializer\Groups(['custom_form:export']), - Assert\Length(max: 15), - ] + Assert\Length(max: 15),] private ?string $retentionTime = null; - #[ - ORM\Column(type: 'boolean', nullable: false, options: ['default' => true]), - SymfonySerializer\Ignore() - ] + #[ORM\Column(type: 'boolean', nullable: false, options: ['default' => true]), + SymfonySerializer\Ignore()] private bool $open = true; - #[ - ApiFilter(RoadizFilter\ArchiveFilter::class), + #[ApiFilter(RoadizFilter\ArchiveFilter::class), ORM\Column(name: 'close_date', type: 'datetime', nullable: true), - SymfonySerializer\Ignore() - ] + SymfonySerializer\Ignore()] private ?\DateTime $closeDate = null; /** * @var Collection */ - #[ - ORM\OneToMany( - mappedBy: 'customForm', - targetEntity: CustomFormField::class, - cascade: ['ALL'], - orphanRemoval: true - ), + #[ORM\OneToMany( + mappedBy: 'customForm', + targetEntity: CustomFormField::class, + cascade: ['ALL'], + orphanRemoval: true + ), ORM\OrderBy(['position' => 'ASC']), - SymfonySerializer\Ignore() - ] + SymfonySerializer\Ignore()] private Collection $fields; /** * @var Collection */ - #[ - ORM\OneToMany( - mappedBy: 'customForm', - targetEntity: CustomFormAnswer::class, - cascade: ['ALL'], - orphanRemoval: true - ), - SymfonySerializer\Ignore - ] + #[ORM\OneToMany( + mappedBy: 'customForm', + targetEntity: CustomFormAnswer::class, + cascade: ['ALL'], + orphanRemoval: true + ), + SymfonySerializer\Ignore] private Collection $customFormAnswers; /** * @var Collection */ - #[ - ORM\OneToMany(mappedBy: 'customForm', targetEntity: NodesCustomForms::class, fetch: 'EXTRA_LAZY'), - SymfonySerializer\Ignore - ] + #[ORM\OneToMany(mappedBy: 'customForm', targetEntity: NodesCustomForms::class, fetch: 'EXTRA_LAZY'), + SymfonySerializer\Ignore] private Collection $nodes; public function __construct() diff --git a/lib/RoadizCoreBundle/src/Entity/CustomFormAnswer.php b/lib/RoadizCoreBundle/src/Entity/CustomFormAnswer.php index 03b3f13bb..cfd989d9f 100644 --- a/lib/RoadizCoreBundle/src/Entity/CustomFormAnswer.php +++ b/lib/RoadizCoreBundle/src/Entity/CustomFormAnswer.php @@ -13,52 +13,42 @@ use Symfony\Component\Serializer\Attribute as SymfonySerializer; use Symfony\Component\Validator\Constraints as Assert; -#[ - ORM\Entity(repositoryClass: CustomFormAnswerRepository::class), +#[ORM\Entity(repositoryClass: CustomFormAnswerRepository::class), ORM\Table(name: 'custom_form_answers'), ORM\Index(columns: ['ip']), ORM\Index(columns: ['submitted_at']), - ORM\Index(columns: ['custom_form_id', 'submitted_at'], name: 'answer_customform_submitted_at') -] + ORM\Index(columns: ['custom_form_id', 'submitted_at'], name: 'answer_customform_submitted_at')] class CustomFormAnswer implements \Stringable, PersistableInterface { use SequentialIdTrait; - #[ - ORM\Column(name: 'ip', type: 'string', length: 46, nullable: false), + #[ORM\Column(name: 'ip', type: 'string', length: 46, nullable: false), SymfonySerializer\Groups(['custom_form_answer']), - Assert\Length(max: 46) - ] + Assert\Length(max: 46)] private string $ip = ''; - #[ - ORM\Column(name: 'submitted_at', type: 'datetime', nullable: false), - SymfonySerializer\Groups(['custom_form_answer']) - ] + #[ORM\Column(name: 'submitted_at', type: 'datetime', nullable: false), + SymfonySerializer\Groups(['custom_form_answer'])] private \DateTime $submittedAt; /** * @var Collection */ - #[ - ORM\OneToMany( - mappedBy: 'customFormAnswer', - targetEntity: CustomFormFieldAttribute::class, - cascade: ['ALL'], - orphanRemoval: true - ), - SymfonySerializer\Groups(['custom_form_answer']) - ] + #[ORM\OneToMany( + mappedBy: 'customFormAnswer', + targetEntity: CustomFormFieldAttribute::class, + cascade: ['ALL'], + orphanRemoval: true + ), + SymfonySerializer\Groups(['custom_form_answer'])] private Collection $answerFields; - #[ - ORM\ManyToOne( - targetEntity: CustomForm::class, - inversedBy: 'customFormAnswers' - ), + #[ORM\ManyToOne( + targetEntity: CustomForm::class, + inversedBy: 'customFormAnswers' + ), ORM\JoinColumn(name: 'custom_form_id', referencedColumnName: 'id', nullable: false, onDelete: 'CASCADE'), - SymfonySerializer\Ignore - ] + SymfonySerializer\Ignore] private CustomForm $customForm; public function __construct() diff --git a/lib/RoadizCoreBundle/src/Entity/CustomFormField.php b/lib/RoadizCoreBundle/src/Entity/CustomFormField.php index 035201ca8..d9ac28ba5 100644 --- a/lib/RoadizCoreBundle/src/Entity/CustomFormField.php +++ b/lib/RoadizCoreBundle/src/Entity/CustomFormField.php @@ -17,8 +17,7 @@ * CustomFormField entities are used to create CustomForms with * custom data structure. */ -#[ - ORM\Entity(repositoryClass: CustomFormFieldRepository::class), +#[ORM\Entity(repositoryClass: CustomFormFieldRepository::class), ORM\Table(name: 'custom_form_fields'), ORM\UniqueConstraint(columns: ['name', 'custom_form_id']), ORM\Index(columns: ['position']), @@ -26,8 +25,7 @@ ORM\Index(columns: ['type']), ORM\Index(columns: ['custom_form_id', 'position'], name: 'cfield_customform_position'), ORM\HasLifecycleCallbacks, - UniqueEntity(fields: ['label', 'customForm']) -] + UniqueEntity(fields: ['label', 'customForm'])] class CustomFormField extends AbstractField implements \Stringable { /** @@ -49,33 +47,26 @@ class CustomFormField extends AbstractField implements \Stringable FieldType::TEXT_T, ]; - #[ - ORM\ManyToOne(targetEntity: CustomForm::class, inversedBy: 'fields'), + #[ORM\ManyToOne(targetEntity: CustomForm::class, inversedBy: 'fields'), ORM\JoinColumn(name: 'custom_form_id', referencedColumnName: 'id', nullable: false, onDelete: 'CASCADE'), - SymfonySerializer\Ignore - ] + SymfonySerializer\Ignore] private CustomForm $customForm; /** * @var Collection */ - #[ - ORM\OneToMany(mappedBy: 'customFormField', targetEntity: CustomFormFieldAttribute::class), - SymfonySerializer\Ignore - ] + #[ORM\OneToMany(mappedBy: 'customFormField', targetEntity: CustomFormFieldAttribute::class), + SymfonySerializer\Ignore] private Collection $customFormFieldAttributes; - #[ - ORM\Column(name: 'field_required', type: 'boolean', nullable: false, options: ['default' => false]), - SymfonySerializer\Groups(['custom_form']) - ] + #[ORM\Column(name: 'field_required', type: 'boolean', nullable: false, options: ['default' => false]), + SymfonySerializer\Groups(['custom_form'])] private bool $required = false; /** * @var string|null https://developer.mozilla.org/fr/docs/Web/HTML/Attributes/autocomplete */ - #[ - ORM\Column(name: 'autocomplete', type: 'string', length: 18, nullable: true), + #[ORM\Column(name: 'autocomplete', type: 'string', length: 18, nullable: true), SymfonySerializer\Groups(['custom_form']), Choice([ 'off', @@ -103,8 +94,7 @@ class CustomFormField extends AbstractField implements \Stringable 'tel-national', 'url', 'photo', - ]) - ] + ])] private ?string $autocomplete = null; public function __construct() diff --git a/lib/RoadizCoreBundle/src/Entity/CustomFormFieldAttribute.php b/lib/RoadizCoreBundle/src/Entity/CustomFormFieldAttribute.php index 6fc651db5..d05331da1 100644 --- a/lib/RoadizCoreBundle/src/Entity/CustomFormFieldAttribute.php +++ b/lib/RoadizCoreBundle/src/Entity/CustomFormFieldAttribute.php @@ -15,37 +15,29 @@ * CustomFormField entities are used to create CustomForms with * custom data structure. */ -#[ - ORM\Entity(repositoryClass: CustomFormFieldAttributeRepository::class), +#[ORM\Entity(repositoryClass: CustomFormFieldAttributeRepository::class), ORM\Table(name: 'custom_form_field_attributes'), ORM\Index(columns: ['custom_form_answer_id', 'custom_form_field_id'], name: 'cffattribute_answer_field'), - ORM\HasLifecycleCallbacks -] + ORM\HasLifecycleCallbacks] class CustomFormFieldAttribute implements \Stringable, PersistableInterface { use SequentialIdTrait; - #[ - ORM\ManyToOne(targetEntity: CustomFormAnswer::class, inversedBy: 'answerFields'), - ORM\JoinColumn(name: 'custom_form_answer_id', referencedColumnName: 'id', nullable: false, onDelete: 'CASCADE') - ] + #[ORM\ManyToOne(targetEntity: CustomFormAnswer::class, inversedBy: 'answerFields'), + ORM\JoinColumn(name: 'custom_form_answer_id', referencedColumnName: 'id', nullable: false, onDelete: 'CASCADE')] protected CustomFormAnswer $customFormAnswer; - #[ - ORM\ManyToOne(targetEntity: CustomFormField::class, inversedBy: 'customFormFieldAttributes'), - ORM\JoinColumn(name: 'custom_form_field_id', referencedColumnName: 'id', nullable: false, onDelete: 'CASCADE') - ] + #[ORM\ManyToOne(targetEntity: CustomFormField::class, inversedBy: 'customFormFieldAttributes'), + ORM\JoinColumn(name: 'custom_form_field_id', referencedColumnName: 'id', nullable: false, onDelete: 'CASCADE')] protected CustomFormField $customFormField; /** * @var Collection */ - #[ - ORM\ManyToMany(targetEntity: Document::class, inversedBy: 'customFormFieldAttributes'), + #[ORM\ManyToMany(targetEntity: Document::class, inversedBy: 'customFormFieldAttributes'), ORM\JoinTable(name: 'custom_form_answers_documents'), ORM\JoinColumn(name: 'customformfieldattribute_id', onDelete: 'CASCADE'), - ORM\InverseJoinColumn(name: 'document_id', onDelete: 'CASCADE') - ] + ORM\InverseJoinColumn(name: 'document_id', onDelete: 'CASCADE')] protected Collection $documents; #[ORM\Column(type: 'text', nullable: true)] diff --git a/lib/RoadizCoreBundle/src/Entity/Document.php b/lib/RoadizCoreBundle/src/Entity/Document.php index e99505a9f..3491c338b 100644 --- a/lib/RoadizCoreBundle/src/Entity/Document.php +++ b/lib/RoadizCoreBundle/src/Entity/Document.php @@ -37,8 +37,7 @@ /** * Documents entity represent a file on server with datetime and naming. */ -#[ - ORM\Entity(repositoryClass: DocumentRepository::class), +#[ORM\Entity(repositoryClass: DocumentRepository::class), ORM\Table(name: 'documents'), ORM\HasLifecycleCallbacks, ORM\Index(columns: ['created_at'], name: 'document_created_at'), @@ -73,8 +72,7 @@ 'copyrightValidSince' => 'include_null_before', 'copyrightValidUntil' => 'include_null_after', ]), - ApiFilter(CopyrightValidFilter::class) -] + ApiFilter(CopyrightValidFilter::class)] class Document implements AdvancedDocumentInterface, HasThumbnailInterface, TimeableInterface, FileHashInterface, DateTimedInterface, PersistableInterface { use SequentialIdTrait; @@ -148,10 +146,8 @@ class Document implements AdvancedDocumentInterface, HasThumbnailInterface, Time #[SymfonySerializer\Ignore] protected ?DocumentInterface $rawDocument = null; - #[ - SymfonySerializer\Ignore, - ORM\Column(name: 'raw', type: 'boolean', nullable: false, options: ['default' => false]) - ] + #[SymfonySerializer\Ignore, + ORM\Column(name: 'raw', type: 'boolean', nullable: false, options: ['default' => false])] protected bool $raw = false; #[ORM\Column(name: 'embedId', type: 'string', length: 250, unique: false, nullable: true)] @@ -584,14 +580,12 @@ public function setFilesize(?int $filesize): static return $this; } - #[ - SymfonySerializer\Groups(['document', 'document_display', 'nodes_sources', 'tag', 'attribute']), + #[SymfonySerializer\Groups(['document', 'document_display', 'nodes_sources', 'tag', 'attribute']), SymfonySerializer\SerializedName('alt'), ApiProperty( description: 'Document alternative text, for img HTML tag. Returns NULL if image is decorative (alt="").', writable: false, - ) - ] + )] #[\Override] public function getAlternativeText(): ?string { diff --git a/lib/RoadizCoreBundle/src/Entity/DocumentTranslation.php b/lib/RoadizCoreBundle/src/Entity/DocumentTranslation.php index 52075a0cf..307e3beb8 100644 --- a/lib/RoadizCoreBundle/src/Entity/DocumentTranslation.php +++ b/lib/RoadizCoreBundle/src/Entity/DocumentTranslation.php @@ -15,12 +15,10 @@ use Symfony\Component\Serializer\Attribute as SymfonySerializer; use Symfony\Component\Validator\Constraints as Assert; -#[ - ORM\Entity(repositoryClass: DocumentTranslationRepository::class), +#[ORM\Entity(repositoryClass: DocumentTranslationRepository::class), ORM\Table(name: 'documents_translations'), ORM\UniqueConstraint(columns: ['document_id', 'translation_id']), - Gedmo\Loggable(logEntryClass: UserLogEntry::class) -] + Gedmo\Loggable(logEntryClass: UserLogEntry::class)] class DocumentTranslation implements Loggable, PersistableInterface { use SequentialIdTrait; diff --git a/lib/RoadizCoreBundle/src/Entity/Folder.php b/lib/RoadizCoreBundle/src/Entity/Folder.php index 4ee0bbe60..24f3d3c9e 100644 --- a/lib/RoadizCoreBundle/src/Entity/Folder.php +++ b/lib/RoadizCoreBundle/src/Entity/Folder.php @@ -29,8 +29,7 @@ /** * Folders entity represent a directory on server with datetime and naming. */ -#[ - ORM\Entity(repositoryClass: FolderRepository::class), +#[ORM\Entity(repositoryClass: FolderRepository::class), ORM\HasLifecycleCallbacks, ORM\Table(name: 'folders'), ORM\Index(columns: ['visible']), @@ -48,8 +47,7 @@ 'position', 'createdAt', 'updatedAt', - ]) -] + ])] class Folder implements DateTimedInterface, FolderInterface, LeafInterface, PersistableInterface { use SequentialIdTrait; diff --git a/lib/RoadizCoreBundle/src/Entity/FolderTranslation.php b/lib/RoadizCoreBundle/src/Entity/FolderTranslation.php index e986058e6..1923cd9c8 100644 --- a/lib/RoadizCoreBundle/src/Entity/FolderTranslation.php +++ b/lib/RoadizCoreBundle/src/Entity/FolderTranslation.php @@ -18,12 +18,10 @@ * * It stores their name. */ -#[ - ORM\Entity(repositoryClass: FolderTranslationRepository::class), +#[ORM\Entity(repositoryClass: FolderTranslationRepository::class), ORM\Table(name: 'folders_translations'), ORM\UniqueConstraint(columns: ['folder_id', 'translation_id']), - UniqueEntity(fields: ['folder', 'translation']) -] + UniqueEntity(fields: ['folder', 'translation'])] class FolderTranslation implements PersistableInterface { use SequentialIdTrait; diff --git a/lib/RoadizCoreBundle/src/Entity/Group.php b/lib/RoadizCoreBundle/src/Entity/Group.php index 1a8074149..815210025 100644 --- a/lib/RoadizCoreBundle/src/Entity/Group.php +++ b/lib/RoadizCoreBundle/src/Entity/Group.php @@ -17,11 +17,9 @@ /** * A group gather User and Roles. */ -#[ - ORM\Entity(repositoryClass: GroupRepository::class), +#[ORM\Entity(repositoryClass: GroupRepository::class), ORM\Table(name: 'usergroups'), - UniqueEntity(fields: ['name']) -] + UniqueEntity(fields: ['name'])] class Group implements PersistableInterface, \Stringable { use SequentialIdTrait; diff --git a/lib/RoadizCoreBundle/src/Entity/Node.php b/lib/RoadizCoreBundle/src/Entity/Node.php index e78424508..4c5b8ef67 100644 --- a/lib/RoadizCoreBundle/src/Entity/Node.php +++ b/lib/RoadizCoreBundle/src/Entity/Node.php @@ -41,8 +41,7 @@ * it describes a document-like object which can be inherited * with *NodesSources* to create complex data structures. */ -#[ - ORM\Entity(repositoryClass: NodeRepository::class), +#[ORM\Entity(repositoryClass: NodeRepository::class), ORM\Table(name: 'nodes'), ORM\Index(columns: ['visible']), ORM\Index(columns: ['status']), @@ -76,8 +75,7 @@ ApiFilter(NodeTypeReachableFilter::class), ApiFilter(NodeTypePublishableFilter::class), ApiFilter(PropertyFilter::class), - ApiFilter(TagGroupFilter::class) -] + ApiFilter(TagGroupFilter::class)] class Node implements DateTimedInterface, LeafInterface, AttributableInterface, Loggable, NodeInterface, \Stringable { use SequentialIdTrait; diff --git a/lib/RoadizCoreBundle/src/Entity/NodeType.php b/lib/RoadizCoreBundle/src/Entity/NodeType.php index 11b636b21..9050cd999 100644 --- a/lib/RoadizCoreBundle/src/Entity/NodeType.php +++ b/lib/RoadizCoreBundle/src/Entity/NodeType.php @@ -19,50 +19,34 @@ */ final class NodeType implements NodeTypeInterface, \Stringable { - #[ - SymfonySerializer\Groups(['node_type:display', 'node_type', 'node_type:import', 'color']), - Assert\Length(max: 7), - ] - protected ?string $color = '#000000'; - #[ - SymfonySerializer\Groups(['node_type:display', 'node_type', 'node_type:import', 'node']), + #[SymfonySerializer\Groups(['node_type:display', 'node_type', 'node_type:import', 'color']), + Assert\Length(max: 7),] + private ?string $color = '#000000'; + #[SymfonySerializer\Groups(['node_type:display', 'node_type', 'node_type:import', 'node']), Assert\NotNull(), Assert\NotBlank(), RoadizAssert\SimpleLatinString(), // Limit discriminator column to 30 characters for indexing optimization - Assert\Length(max: 30) - ] + Assert\Length(max: 30)] private string $name = ''; - #[ - SymfonySerializer\Groups(['node_type:display', 'node_type', 'node_type:import', 'node']), + #[SymfonySerializer\Groups(['node_type:display', 'node_type', 'node_type:import', 'node']), Assert\NotNull(), Assert\NotBlank(), - Assert\Length(max: 250) - ] + Assert\Length(max: 250)] private string $displayName = ''; - #[ - SymfonySerializer\Groups(['node_type', 'node_type:import']), - ] + #[SymfonySerializer\Groups(['node_type', 'node_type:import']),] private ?string $description = null; - #[ - SymfonySerializer\Groups(['node_type:display', 'node_type', 'node_type:import']), - ] + #[SymfonySerializer\Groups(['node_type:display', 'node_type', 'node_type:import']),] private bool $visible = true; - #[ - SymfonySerializer\Groups(['node_type', 'node_type:import']), - ] + #[SymfonySerializer\Groups(['node_type', 'node_type:import']),] private bool $publishable = false; /** * @var bool define if this node-type produces nodes that will have attributes */ - #[ - SymfonySerializer\Groups(['node_type', 'node_type:import']), - ] + #[SymfonySerializer\Groups(['node_type', 'node_type:import']),] private bool $attributable = false; - #[ - SymfonySerializer\Groups(['node_type', 'node_type:import']), - ] + #[SymfonySerializer\Groups(['node_type', 'node_type:import']),] private bool $sortingAttributesByWeight = false; /** * Define if this node-type produces nodes that will be @@ -70,45 +54,31 @@ final class NodeType implements NodeTypeInterface, \Stringable * * Typically, if a node has a URL. */ - #[ - SymfonySerializer\Groups(['node_type', 'node_type:import']), - ] + #[SymfonySerializer\Groups(['node_type', 'node_type:import']),] private bool $reachable = true; - #[ - SymfonySerializer\Groups(['node_type', 'node_type:import']), - ] + #[SymfonySerializer\Groups(['node_type', 'node_type:import']),] private bool $hidingNodes = false; - #[ - SymfonySerializer\Groups(['node_type', 'node_type:import']), - ] + #[SymfonySerializer\Groups(['node_type', 'node_type:import']),] private bool $hidingNonReachableNodes = false; /** * @var Collection */ - #[ - SymfonySerializer\Groups(['node_type', 'node_type:import']), - ] + #[SymfonySerializer\Groups(['node_type', 'node_type:import']),] private Collection $fields; - #[ - SymfonySerializer\Groups(['node_type', 'node_type:import']), + #[SymfonySerializer\Groups(['node_type', 'node_type:import']), Assert\GreaterThanOrEqual(value: 0), - Assert\NotNull - ] + Assert\NotNull] // @phpstan-ignore-next-line private ?int $defaultTtl = 0; /** * Define if this node-type title will be indexed during its parent indexation. */ - #[ - SymfonySerializer\Groups(['node_type', 'node_type:import']), - ] + #[SymfonySerializer\Groups(['node_type', 'node_type:import']),] private bool $searchable = true; /** * Define if this node type is allowed in the first position in node-type selector on node creation. */ - #[ - SymfonySerializer\Groups(['node_type', 'node_type:import']), - ] + #[SymfonySerializer\Groups(['node_type', 'node_type:import']),] private bool $highlighted = false; public function __construct() diff --git a/lib/RoadizCoreBundle/src/Entity/NodeTypeDecorator.php b/lib/RoadizCoreBundle/src/Entity/NodeTypeDecorator.php index c9315fee4..e1d0bfd3e 100644 --- a/lib/RoadizCoreBundle/src/Entity/NodeTypeDecorator.php +++ b/lib/RoadizCoreBundle/src/Entity/NodeTypeDecorator.php @@ -11,12 +11,10 @@ use RZ\Roadiz\CoreBundle\Repository\NodeTypeDecoratorRepository; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; -#[ - ORM\Entity(repositoryClass: NodeTypeDecoratorRepository::class), +#[ORM\Entity(repositoryClass: NodeTypeDecoratorRepository::class), ORM\Table(name: 'node_type_decorators'), UniqueEntity(fields: ['path', 'property']), - ORM\Index(columns: ['path'], name: 'idx_ntd_path'), -] + ORM\Index(columns: ['path'], name: 'idx_ntd_path'),] class NodeTypeDecorator implements PersistableInterface, \Stringable { use SequentialIdTrait; diff --git a/lib/RoadizCoreBundle/src/Entity/NodeTypeField.php b/lib/RoadizCoreBundle/src/Entity/NodeTypeField.php index a75f0dba9..4a462d30c 100644 --- a/lib/RoadizCoreBundle/src/Entity/NodeTypeField.php +++ b/lib/RoadizCoreBundle/src/Entity/NodeTypeField.php @@ -19,88 +19,58 @@ #[RoadizAssert\NodeTypeField] final class NodeTypeField extends AbstractField implements NodeTypeFieldInterface, SerializableInterface { - #[ - Serializer\Groups(['node_type', 'node_type:import', 'setting']), + #[Serializer\Groups(['node_type', 'node_type:import', 'setting']), Assert\Length(max: 50), RoadizAssert\NonSqlReservedWord(), - RoadizAssert\SimpleLatinString() - ] + RoadizAssert\SimpleLatinString()] protected string $name; /** * If current field data should be the same over translations or not. */ - #[ - Serializer\Groups(['node_type', 'node_type:import']), - ] + #[Serializer\Groups(['node_type', 'node_type:import']),] private bool $universal = false; /** * Exclude current field from full-text search engines. */ - #[ - Serializer\Groups(['node_type', 'node_type:import']), - ] + #[Serializer\Groups(['node_type', 'node_type:import']),] private bool $excludeFromSearch = false; - #[ - Serializer\Ignore - ] + #[Serializer\Ignore] private NodeTypeInterface $nodeType; - #[ - Serializer\Groups(['node_type', 'node_type:import']), - ] + #[Serializer\Groups(['node_type', 'node_type:import']),] private ?string $serializationExclusionExpression = null; - #[ - Serializer\Groups(['node_type', 'node_type:import']), - ] + #[Serializer\Groups(['node_type', 'node_type:import']),] private ?array $serializationGroups = null; - #[ - Serializer\Groups(['node_type', 'node_type:import']), - ] + #[Serializer\Groups(['node_type', 'node_type:import']),] private ?array $normalizationContext = null; - #[ - Serializer\Groups(['node_type', 'node_type:import']), - ] + #[Serializer\Groups(['node_type', 'node_type:import']),] private ?int $serializationMaxDepth = null; - #[ - Serializer\Groups(['node_type', 'node_type:import']), - ] + #[Serializer\Groups(['node_type', 'node_type:import']),] private bool $excludedFromSerialization = false; - #[ - Serializer\Groups(['node_type', 'node_type:import']), - ] + #[Serializer\Groups(['node_type', 'node_type:import']),] private ?int $minLength = null; - #[ - Serializer\Groups(['node_type', 'node_type:import']), - ] + #[Serializer\Groups(['node_type', 'node_type:import']),] private ?int $maxLength = null; - #[ - Serializer\Groups(['node_type', 'node_type:import']), - ] + #[Serializer\Groups(['node_type', 'node_type:import']),] private bool $indexed = false; - #[ - Serializer\Groups(['node_type', 'node_type:import']), - ] + #[Serializer\Groups(['node_type', 'node_type:import']),] private bool $visible = true; - #[ - Serializer\Groups(['node_type', 'node_type:import']), - ] + #[Serializer\Groups(['node_type', 'node_type:import']),] private bool $required = false; - #[ - Serializer\Groups(['node_type']) - ] + #[Serializer\Groups(['node_type'])] #[\Override] public function getNodeTypeName(): string { diff --git a/lib/RoadizCoreBundle/src/Entity/NodesCustomForms.php b/lib/RoadizCoreBundle/src/Entity/NodesCustomForms.php index 326e75c22..1cb1daef6 100644 --- a/lib/RoadizCoreBundle/src/Entity/NodesCustomForms.php +++ b/lib/RoadizCoreBundle/src/Entity/NodesCustomForms.php @@ -16,14 +16,12 @@ * Describes a complex ManyToMany relation * between Nodes, CustomForms and NodeTypeFields. */ -#[ - ORM\Entity(repositoryClass: NodesCustomFormsRepository::class), +#[ORM\Entity(repositoryClass: NodesCustomFormsRepository::class), ORM\Table(name: 'nodes_custom_forms'), ORM\HasLifecycleCallbacks, ORM\Index(columns: ['position']), ORM\Index(columns: ['node_id', 'position'], name: 'customform_node_position'), - ORM\Index(columns: ['node_id', 'field_name', 'position'], name: 'customform_node_field_position') -] + ORM\Index(columns: ['node_id', 'field_name', 'position'], name: 'customform_node_field_position')] class NodesCustomForms implements PositionedInterface, PersistableInterface { use SequentialIdTrait; diff --git a/lib/RoadizCoreBundle/src/Entity/NodesSources.php b/lib/RoadizCoreBundle/src/Entity/NodesSources.php index b7fcbb23e..5ca100dcc 100644 --- a/lib/RoadizCoreBundle/src/Entity/NodesSources.php +++ b/lib/RoadizCoreBundle/src/Entity/NodesSources.php @@ -31,8 +31,7 @@ /** * NodesSources store Node content according to a translation and a NodeType. */ -#[ - ORM\Entity(repositoryClass: NodesSourcesRepository::class), +#[ORM\Entity(repositoryClass: NodesSourcesRepository::class), ORM\Table(name: 'nodes_sources'), ORM\Index(columns: ['discr']), ORM\Index(columns: ['title']), @@ -57,8 +56,7 @@ ApiFilter(NodeTypeReachableFilter::class), ApiFilter(NodeTypePublishableFilter::class), ApiFilter(RoadizFilter\LocaleFilter::class), - ApiFilter(RoadizFilter\TagGroupFilter::class), -] + ApiFilter(RoadizFilter\TagGroupFilter::class),] class NodesSources implements PersistableInterface, Loggable, \Stringable { use SequentialIdTrait; @@ -459,9 +457,9 @@ public function getParent(): ?NodesSources $nodeSources = $parent->getNodeSourcesByTranslation($this->translation)->first(); return $nodeSources ?: null; - } else { - return null; } + + return null; } #[\Override] diff --git a/lib/RoadizCoreBundle/src/Entity/NodesSourcesDocuments.php b/lib/RoadizCoreBundle/src/Entity/NodesSourcesDocuments.php index 440bca1f1..ac0efce4d 100644 --- a/lib/RoadizCoreBundle/src/Entity/NodesSourcesDocuments.php +++ b/lib/RoadizCoreBundle/src/Entity/NodesSourcesDocuments.php @@ -20,14 +20,12 @@ * Describes a complex ManyToMany relation * between NodesSources, Documents and NodeTypeFields. */ -#[ - ORM\Entity(repositoryClass: NodesSourcesDocumentsRepository::class), +#[ORM\Entity(repositoryClass: NodesSourcesDocumentsRepository::class), ORM\Table(name: 'nodes_sources_documents'), ORM\HasLifecycleCallbacks, ORM\Index(columns: ['position']), ORM\Index(columns: ['ns_id', 'field_name'], name: 'nsdoc_field'), - ORM\Index(columns: ['ns_id', 'field_name', 'position'], name: 'nsdoc_field_position') -] + ORM\Index(columns: ['ns_id', 'field_name', 'position'], name: 'nsdoc_field_position')] class NodesSourcesDocuments implements PositionedInterface, PersistableInterface, ContextualizedDocumentInterface { use SequentialIdTrait; diff --git a/lib/RoadizCoreBundle/src/Entity/NodesTags.php b/lib/RoadizCoreBundle/src/Entity/NodesTags.php index 4b56eddb0..4e8b74fe3 100644 --- a/lib/RoadizCoreBundle/src/Entity/NodesTags.php +++ b/lib/RoadizCoreBundle/src/Entity/NodesTags.php @@ -12,23 +12,20 @@ use RZ\Roadiz\CoreBundle\Repository\NodesTagsRepository; use Symfony\Component\Serializer\Attribute as SymfonySerializer; -#[ - ORM\Entity(repositoryClass: NodesTagsRepository::class), +#[ORM\Entity(repositoryClass: NodesTagsRepository::class), ORM\Table(name: 'nodes_tags'), ORM\HasLifecycleCallbacks, ORM\Index(columns: ['node_id', 'position'], name: 'nodes_tags_node_id_position'), ORM\Index(columns: ['tag_id', 'position'], name: 'nodes_tags_tag_id_position'), ORM\Index(columns: ['position'], name: 'nodes_tags_position'), ORM\Index(columns: ['tag_id'], name: 'nodes_tags_tag_id'), - ORM\Index(columns: ['node_id'], name: 'nodes_tags_node_id'), -] + ORM\Index(columns: ['node_id'], name: 'nodes_tags_node_id'),] class NodesTags implements PositionedInterface, PersistableInterface { use UuidTrait; use PositionedTrait; - #[ - ORM\ManyToOne(targetEntity: Node::class, inversedBy: 'nodesTags'), + #[ORM\ManyToOne(targetEntity: Node::class, inversedBy: 'nodesTags'), ORM\JoinColumn( name: 'node_id', referencedColumnName: 'id', @@ -36,12 +33,10 @@ class NodesTags implements PositionedInterface, PersistableInterface nullable: false, onDelete: 'CASCADE' ), - SymfonySerializer\Ignore, - ] + SymfonySerializer\Ignore,] private Node $node; - #[ - ORM\ManyToOne(targetEntity: Tag::class, inversedBy: 'nodesTags'), + #[ORM\ManyToOne(targetEntity: Tag::class, inversedBy: 'nodesTags'), ORM\JoinColumn( name: 'tag_id', referencedColumnName: 'id', @@ -49,14 +44,11 @@ class NodesTags implements PositionedInterface, PersistableInterface nullable: false, onDelete: 'CASCADE' ), - SymfonySerializer\Groups(['nodes_sources', 'nodes_sources_base', 'node']), - ] + SymfonySerializer\Groups(['nodes_sources', 'nodes_sources_base', 'node']),] private Tag $tag; - #[ - ORM\Column(type: 'float', nullable: false, options: ['default' => 1]), - SymfonySerializer\Ignore, - ] + #[ORM\Column(type: 'float', nullable: false, options: ['default' => 1]), + SymfonySerializer\Ignore,] protected float $position = 0.0; public function getNode(): Node diff --git a/lib/RoadizCoreBundle/src/Entity/NodesToNodes.php b/lib/RoadizCoreBundle/src/Entity/NodesToNodes.php index c0d49e855..e8bc0c09f 100644 --- a/lib/RoadizCoreBundle/src/Entity/NodesToNodes.php +++ b/lib/RoadizCoreBundle/src/Entity/NodesToNodes.php @@ -16,16 +16,14 @@ * Describes a complex ManyToMany relation * between two Nodes and NodeTypeFields. */ -#[ - ORM\Entity(repositoryClass: NodesToNodesRepository::class), +#[ORM\Entity(repositoryClass: NodesToNodesRepository::class), ORM\Table(name: 'nodes_to_nodes'), ORM\HasLifecycleCallbacks, ORM\Index(columns: ['position']), ORM\Index(columns: ['node_a_id', 'field_name'], name: 'node_a_field'), ORM\Index(columns: ['node_a_id', 'field_name', 'position'], name: 'node_a_field_position'), ORM\Index(columns: ['node_b_id', 'field_name'], name: 'node_b_field'), - ORM\Index(columns: ['node_b_id', 'field_name', 'position'], name: 'node_b_field_position') -] + ORM\Index(columns: ['node_b_id', 'field_name', 'position'], name: 'node_b_field_position')] class NodesToNodes implements PositionedInterface, PersistableInterface { use SequentialIdTrait; diff --git a/lib/RoadizCoreBundle/src/Entity/Realm.php b/lib/RoadizCoreBundle/src/Entity/Realm.php index c291fa040..90af71a0d 100644 --- a/lib/RoadizCoreBundle/src/Entity/Realm.php +++ b/lib/RoadizCoreBundle/src/Entity/Realm.php @@ -24,8 +24,7 @@ * It supports plain_password (in query string), role-based and user-based authentication. * All behaviours except for serializationGroups are only applied when using API WebResponse. */ -#[ - ORM\Entity(repositoryClass: RealmRepository::class), +#[ORM\Entity(repositoryClass: RealmRepository::class), ORM\Table(name: 'realms'), ORM\Index(columns: ['type'], name: 'realms_type'), ORM\Index(columns: ['behaviour'], name: 'realms_behaviour'), @@ -35,8 +34,7 @@ 'type' => 'exact', 'behaviour' => 'exact', 'name' => 'exact', - ]) -] + ])] class Realm implements RealmInterface { use SequentialIdTrait; diff --git a/lib/RoadizCoreBundle/src/Entity/RealmNode.php b/lib/RoadizCoreBundle/src/Entity/RealmNode.php index 482d8c6b5..c5a9d13fc 100644 --- a/lib/RoadizCoreBundle/src/Entity/RealmNode.php +++ b/lib/RoadizCoreBundle/src/Entity/RealmNode.php @@ -13,16 +13,14 @@ use Symfony\Component\Serializer\Attribute as SymfonySerializer; use Symfony\Component\Validator\Constraints as Assert; -#[ - ORM\Entity(repositoryClass: RealmNodeRepository::class), +#[ORM\Entity(repositoryClass: RealmNodeRepository::class), ORM\Table(name: 'realms_nodes'), ORM\Index(columns: ['inheritance_type'], name: 'realms_nodes_inheritance_type'), ORM\Index(columns: ['realm_id'], name: 'realms_nodes_realm'), ORM\Index(columns: ['node_id'], name: 'realms_nodes_node'), ORM\Index(columns: ['node_id', 'inheritance_type'], name: 'realms_nodes_node_inheritance_type'), ORM\UniqueConstraint(name: 'realms_nodes_unique', columns: ['node_id', 'realm_id']), - UniqueEntity(fields: ['node', 'realm']) -] + UniqueEntity(fields: ['node', 'realm'])] class RealmNode implements PersistableInterface { use SequentialIdTrait; diff --git a/lib/RoadizCoreBundle/src/Entity/Redirection.php b/lib/RoadizCoreBundle/src/Entity/Redirection.php index 062f0d435..78e3b8298 100644 --- a/lib/RoadizCoreBundle/src/Entity/Redirection.php +++ b/lib/RoadizCoreBundle/src/Entity/Redirection.php @@ -18,15 +18,13 @@ /** * Http redirection which are editable by BO users. */ -#[ - ORM\Entity(repositoryClass: RedirectionRepository::class), +#[ORM\Entity(repositoryClass: RedirectionRepository::class), ORM\Table(name: 'redirections'), ORM\HasLifecycleCallbacks, UniqueEntity(fields: ['query']), ORM\Index(columns: ['use_count'], name: 'redirection_use_count'), ORM\Index(columns: ['created_at'], name: 'redirection_created_at'), - ORM\Index(columns: ['updated_at'], name: 'redirection_updated_at'), -] + ORM\Index(columns: ['updated_at'], name: 'redirection_updated_at'),] class Redirection implements DateTimedInterface, PersistableInterface { use SequentialIdTrait; diff --git a/lib/RoadizCoreBundle/src/Entity/Setting.php b/lib/RoadizCoreBundle/src/Entity/Setting.php index 8db29e73c..8079c9c8b 100644 --- a/lib/RoadizCoreBundle/src/Entity/Setting.php +++ b/lib/RoadizCoreBundle/src/Entity/Setting.php @@ -18,14 +18,12 @@ /** * Settings entity are a simple key-value configuration system. */ -#[ - ORM\Entity(repositoryClass: SettingRepository::class), +#[ORM\Entity(repositoryClass: SettingRepository::class), ORM\Table(name: 'settings'), ORM\Index(columns: ['type']), ORM\Index(columns: ['name']), ORM\Index(columns: ['visible']), - UniqueEntity(fields: ['name']), -] + UniqueEntity(fields: ['name']),] class Setting implements PersistableInterface { use SequentialIdTrait; diff --git a/lib/RoadizCoreBundle/src/Entity/SettingGroup.php b/lib/RoadizCoreBundle/src/Entity/SettingGroup.php index e6cb88694..da6ea799f 100644 --- a/lib/RoadizCoreBundle/src/Entity/SettingGroup.php +++ b/lib/RoadizCoreBundle/src/Entity/SettingGroup.php @@ -17,11 +17,9 @@ /** * Settings entity are a simple key-value configuration system. */ -#[ - ORM\Entity(repositoryClass: SettingGroupRepository::class), +#[ORM\Entity(repositoryClass: SettingGroupRepository::class), ORM\Table(name: 'settings_groups'), - UniqueEntity(fields: ['name']) -] + UniqueEntity(fields: ['name'])] class SettingGroup implements PersistableInterface, \Stringable { use SequentialIdTrait; diff --git a/lib/RoadizCoreBundle/src/Entity/StackType.php b/lib/RoadizCoreBundle/src/Entity/StackType.php index 79eaf7523..3000c6e88 100644 --- a/lib/RoadizCoreBundle/src/Entity/StackType.php +++ b/lib/RoadizCoreBundle/src/Entity/StackType.php @@ -8,10 +8,8 @@ use RZ\Roadiz\CoreBundle\Repository\StackTypeRepository; use Symfony\Component\Validator\Constraints as Assert; -#[ - ORM\Entity(repositoryClass: StackTypeRepository::class), - ORM\Table(name: 'stack_types'), -] +#[ORM\Entity(repositoryClass: StackTypeRepository::class), + ORM\Table(name: 'stack_types'),] class StackType { public function __construct( diff --git a/lib/RoadizCoreBundle/src/Entity/Tag.php b/lib/RoadizCoreBundle/src/Entity/Tag.php index d8bb459d5..2d95c0db8 100644 --- a/lib/RoadizCoreBundle/src/Entity/Tag.php +++ b/lib/RoadizCoreBundle/src/Entity/Tag.php @@ -29,8 +29,7 @@ /** * Tags are hierarchical entities used to qualify Nodes. */ -#[ - ORM\Entity(repositoryClass: TagRepository::class), +#[ORM\Entity(repositoryClass: TagRepository::class), ORM\HasLifecycleCallbacks, ORM\Table(name: 'tags'), ORM\Index(columns: ['visible']), @@ -50,8 +49,7 @@ 'position', 'createdAt', 'updatedAt', - ]) -] + ])] class Tag implements DateTimedInterface, LeafInterface, PersistableInterface, \Stringable { use SequentialIdTrait; diff --git a/lib/RoadizCoreBundle/src/Entity/TagTranslation.php b/lib/RoadizCoreBundle/src/Entity/TagTranslation.php index 096887b80..3ef58d7f2 100644 --- a/lib/RoadizCoreBundle/src/Entity/TagTranslation.php +++ b/lib/RoadizCoreBundle/src/Entity/TagTranslation.php @@ -21,13 +21,11 @@ * * It stores their name and description. */ -#[ - ORM\Entity(repositoryClass: TagTranslationRepository::class), +#[ORM\Entity(repositoryClass: TagTranslationRepository::class), ORM\Table(name: 'tags_translations'), ORM\UniqueConstraint(columns: ['tag_id', 'translation_id']), Gedmo\Loggable(logEntryClass: UserLogEntry::class), - UniqueEntity(fields: ['tag', 'translation']) -] + UniqueEntity(fields: ['tag', 'translation'])] class TagTranslation implements PersistableInterface { use SequentialIdTrait; diff --git a/lib/RoadizCoreBundle/src/Entity/TagTranslationDocuments.php b/lib/RoadizCoreBundle/src/Entity/TagTranslationDocuments.php index 1f98b83bf..a6a2d5164 100644 --- a/lib/RoadizCoreBundle/src/Entity/TagTranslationDocuments.php +++ b/lib/RoadizCoreBundle/src/Entity/TagTranslationDocuments.php @@ -16,13 +16,11 @@ * Describes a complex ManyToMany relation * between TagTranslation and Documents. */ -#[ - ORM\Entity(repositoryClass: TagTranslationDocumentsRepository::class), +#[ORM\Entity(repositoryClass: TagTranslationDocumentsRepository::class), ORM\Table(name: 'tags_translations_documents'), ORM\HasLifecycleCallbacks, ORM\Index(columns: ['position']), - ORM\Index(columns: ['tag_translation_id', 'position'], name: 'tagtranslation_position') -] + ORM\Index(columns: ['tag_translation_id', 'position'], name: 'tagtranslation_position')] class TagTranslationDocuments implements PositionedInterface, PersistableInterface { use SequentialIdTrait; diff --git a/lib/RoadizCoreBundle/src/Entity/Translation.php b/lib/RoadizCoreBundle/src/Entity/Translation.php index 351da472c..b654eec98 100644 --- a/lib/RoadizCoreBundle/src/Entity/Translation.php +++ b/lib/RoadizCoreBundle/src/Entity/Translation.php @@ -24,8 +24,7 @@ * Translations describe language locales to be used by Nodes, * Tags, UrlAliases and Documents. */ -#[ - ORM\Entity(repositoryClass: TranslationRepository::class), +#[ORM\Entity(repositoryClass: TranslationRepository::class), ORM\Table(name: 'translations'), ORM\HasLifecycleCallbacks, ORM\Index(columns: ['available']), @@ -53,8 +52,7 @@ ApiFilter(BaseFilter\SearchFilter::class, properties: [ 'locale' => 'exact', 'name' => 'exact', - ]) -] + ])] class Translation implements TranslationInterface { use SequentialIdTrait; diff --git a/lib/RoadizCoreBundle/src/Entity/UrlAlias.php b/lib/RoadizCoreBundle/src/Entity/UrlAlias.php index 6bf0c0a56..5fbfeea6a 100644 --- a/lib/RoadizCoreBundle/src/Entity/UrlAlias.php +++ b/lib/RoadizCoreBundle/src/Entity/UrlAlias.php @@ -16,10 +16,8 @@ /** * UrlAliases are used to translate Nodes URLs. */ -#[ - ORM\Entity(repositoryClass: UrlAliasRepository::class), - ORM\Table(name: 'url_aliases') -] +#[ORM\Entity(repositoryClass: UrlAliasRepository::class), + ORM\Table(name: 'url_aliases')] class UrlAlias implements PersistableInterface, \Stringable { use SequentialIdTrait; diff --git a/lib/RoadizCoreBundle/src/Entity/User.php b/lib/RoadizCoreBundle/src/Entity/User.php index 7199c7177..3a15c9744 100644 --- a/lib/RoadizCoreBundle/src/Entity/User.php +++ b/lib/RoadizCoreBundle/src/Entity/User.php @@ -21,8 +21,7 @@ use Symfony\Component\Serializer\Attribute as Serializer; use Symfony\Component\Validator\Constraints as Assert; -#[ - ORM\Entity(repositoryClass: UserRepository::class), +#[ORM\Entity(repositoryClass: UserRepository::class), ORM\Table(name: 'users'), ORM\Index(columns: ['username'], name: 'idx_users_username'), ORM\Index(columns: ['email'], name: 'idx_users_email'), @@ -38,8 +37,7 @@ ORM\HasLifecycleCallbacks, UniqueEntity('email'), UniqueEntity('username'), - ApiFilter(PropertyFilter::class), -] + ApiFilter(PropertyFilter::class),] class User extends AbstractHuman implements UserInterface, AdvancedUserInterface, EquatableInterface, PasswordAuthenticatedUserInterface, \Stringable { /** @@ -186,9 +184,9 @@ public function getIdentifier(): string return $this->getFirstName().' '.$this->getLastName(); } elseif ('' != $this->getFirstName()) { return $this->getFirstName(); - } else { - return $this->getUsername(); } + + return $this->getUsername(); } #[Serializer\SerializedName('identifier')] diff --git a/lib/RoadizCoreBundle/src/Entity/UserLogEntry.php b/lib/RoadizCoreBundle/src/Entity/UserLogEntry.php index 84dc6b61f..73e731d47 100644 --- a/lib/RoadizCoreBundle/src/Entity/UserLogEntry.php +++ b/lib/RoadizCoreBundle/src/Entity/UserLogEntry.php @@ -11,14 +11,12 @@ /** * Add User to Gedmo\Loggable\Entity\LogEntry. */ -#[ - ORM\Entity(repositoryClass: UserLogEntryRepository::class), +#[ORM\Entity(repositoryClass: UserLogEntryRepository::class), ORM\Table(name: 'user_log_entries', options: ['row_format' => 'DYNAMIC']), ORM\Index(columns: ['object_class'], name: 'log_class_lookup_idx'), ORM\Index(columns: ['logged_at'], name: 'log_date_lookup_idx'), ORM\Index(columns: ['username'], name: 'log_user_lookup_idx'), - ORM\Index(columns: ['object_id', 'object_class', 'version'], name: 'log_version_lookup_idx') -] + ORM\Index(columns: ['object_id', 'object_class', 'version'], name: 'log_version_lookup_idx')] class UserLogEntry extends AbstractLogEntry { } diff --git a/lib/RoadizCoreBundle/src/Entity/Webhook.php b/lib/RoadizCoreBundle/src/Entity/Webhook.php index 91dc85d2f..30f4e0c6e 100644 --- a/lib/RoadizCoreBundle/src/Entity/Webhook.php +++ b/lib/RoadizCoreBundle/src/Entity/Webhook.php @@ -12,8 +12,7 @@ use Symfony\Component\Serializer\Attribute as SymfonySerializer; use Symfony\Component\Validator\Constraints as Assert; -#[ - ORM\Entity(repositoryClass: WebhookRepository::class), +#[ORM\Entity(repositoryClass: WebhookRepository::class), ORM\Table(name: 'webhooks'), ORM\Index(columns: ['message_type'], name: 'webhook_message_type'), ORM\Index(columns: ['created_at'], name: 'webhook_created_at'), @@ -21,8 +20,7 @@ ORM\Index(columns: ['automatic'], name: 'webhook_automatic'), ORM\Index(columns: ['root_node'], name: 'webhook_root_node'), ORM\Index(columns: ['last_triggered_at'], name: 'webhook_last_triggered_at'), - ORM\HasLifecycleCallbacks -] + ORM\HasLifecycleCallbacks] class Webhook implements WebhookInterface { use UuidTrait; diff --git a/lib/RoadizCoreBundle/src/EntityHandler/FolderHandler.php b/lib/RoadizCoreBundle/src/EntityHandler/FolderHandler.php index 1a97f34db..4d98ebf69 100644 --- a/lib/RoadizCoreBundle/src/EntityHandler/FolderHandler.php +++ b/lib/RoadizCoreBundle/src/EntityHandler/FolderHandler.php @@ -85,9 +85,9 @@ public function cleanPositions(bool $setPositions = true): float $parentHandler->setFolder($parent); return $parentHandler->cleanChildrenPositions($setPositions); - } else { - return $this->cleanRootFoldersPositions($setPositions); } + + return $this->cleanRootFoldersPositions($setPositions); } /** diff --git a/lib/RoadizCoreBundle/src/EntityHandler/NodeHandler.php b/lib/RoadizCoreBundle/src/EntityHandler/NodeHandler.php index c25249915..23a325542 100644 --- a/lib/RoadizCoreBundle/src/EntityHandler/NodeHandler.php +++ b/lib/RoadizCoreBundle/src/EntityHandler/NodeHandler.php @@ -402,9 +402,9 @@ public function cleanPositions(bool $setPositions = true): float $parentHandler->setNode($parent); return $parentHandler->cleanChildrenPositions($setPositions); - } else { - return $this->cleanRootNodesPositions($setPositions); } + + return $this->cleanRootNodesPositions($setPositions); } /** diff --git a/lib/RoadizCoreBundle/src/EntityHandler/NodesSourcesHandler.php b/lib/RoadizCoreBundle/src/EntityHandler/NodesSourcesHandler.php index ab3c2d8c6..57a2c9985 100644 --- a/lib/RoadizCoreBundle/src/EntityHandler/NodesSourcesHandler.php +++ b/lib/RoadizCoreBundle/src/EntityHandler/NodesSourcesHandler.php @@ -319,11 +319,10 @@ public function getFirstSibling( $parentHandler->setNodeSource($this->nodeSource->getParent()); return $parentHandler->getFirstChild($criteria, $order); - } else { - $criteria['node.parent'] = null; - - return $this->getFirstChild($criteria, $order); } + $criteria['node.parent'] = null; + + return $this->getFirstChild($criteria, $order); } /** @@ -340,11 +339,10 @@ public function getLastSibling( $parentHandler->setNodeSource($this->nodeSource->getParent()); return $parentHandler->getLastChild($criteria, $order); - } else { - $criteria['node.parent'] = null; - - return $this->getLastChild($criteria, $order); } + $criteria['node.parent'] = null; + + return $this->getLastChild($criteria, $order); } /** diff --git a/lib/RoadizCoreBundle/src/EntityHandler/TagHandler.php b/lib/RoadizCoreBundle/src/EntityHandler/TagHandler.php index 20eb42999..5444f55bb 100644 --- a/lib/RoadizCoreBundle/src/EntityHandler/TagHandler.php +++ b/lib/RoadizCoreBundle/src/EntityHandler/TagHandler.php @@ -92,9 +92,9 @@ public function cleanPositions(bool $setPositions = true): float $tagHandler->setTag($parent); return $tagHandler->cleanChildrenPositions($setPositions); - } else { - return $this->cleanRootTagsPositions($setPositions); } + + return $this->cleanRootTagsPositions($setPositions); } /** diff --git a/lib/RoadizCoreBundle/src/EventSubscriber/AutomaticWebhookSubscriber.php b/lib/RoadizCoreBundle/src/EventSubscriber/AutomaticWebhookSubscriber.php index 3a458c8ea..644990685 100644 --- a/lib/RoadizCoreBundle/src/EventSubscriber/AutomaticWebhookSubscriber.php +++ b/lib/RoadizCoreBundle/src/EventSubscriber/AutomaticWebhookSubscriber.php @@ -49,7 +49,7 @@ public static function getSubscribedEvents(): array ]; } - protected function isEventRelatedToNode(mixed $event): bool + private function isEventRelatedToNode(mixed $event): bool { return $event instanceof Event || $event instanceof NodeVisibilityChangedEvent diff --git a/lib/RoadizCoreBundle/src/EventSubscriber/CloudflareCacheEventSubscriber.php b/lib/RoadizCoreBundle/src/EventSubscriber/CloudflareCacheEventSubscriber.php index a885a8714..16338d919 100644 --- a/lib/RoadizCoreBundle/src/EventSubscriber/CloudflareCacheEventSubscriber.php +++ b/lib/RoadizCoreBundle/src/EventSubscriber/CloudflareCacheEventSubscriber.php @@ -39,7 +39,7 @@ public static function getSubscribedEvents(): array ]; } - protected function supportConfig(): bool + private function supportConfig(): bool { return null !== $this->reverseProxyCacheLocator->getCloudflareProxyCache() && ( @@ -118,7 +118,7 @@ private function getCloudflareCacheProxy(): CloudflareProxyCache /** * @throws \JsonException */ - protected function createRequest(array $body): HttpRequestMessageInterface + private function createRequest(array $body): HttpRequestMessageInterface { $headers = [ 'Content-type' => 'application/json', @@ -151,7 +151,7 @@ protected function createRequest(array $body): HttpRequestMessageInterface /** * @throws \JsonException */ - protected function createBanRequest(): HttpRequestMessageInterface + private function createBanRequest(): HttpRequestMessageInterface { return $this->createRequest([ 'purge_everything' => true, @@ -163,14 +163,14 @@ protected function createBanRequest(): HttpRequestMessageInterface * * @throws \JsonException */ - protected function createPurgeRequest(array $uris = []): HttpRequestMessageInterface + private function createPurgeRequest(array $uris = []): HttpRequestMessageInterface { return $this->createRequest([ 'files' => $uris, ]); } - protected function sendRequest(HttpRequestMessageInterface $requestMessage): void + private function sendRequest(HttpRequestMessageInterface $requestMessage): void { try { $this->bus->dispatch(new Envelope($requestMessage)); diff --git a/lib/RoadizCoreBundle/src/EventSubscriber/JwtAuthenticationSuccessEventSubscriber.php b/lib/RoadizCoreBundle/src/EventSubscriber/JwtAuthenticationSuccessEventSubscriber.php index 37dc3c492..abafe5412 100644 --- a/lib/RoadizCoreBundle/src/EventSubscriber/JwtAuthenticationSuccessEventSubscriber.php +++ b/lib/RoadizCoreBundle/src/EventSubscriber/JwtAuthenticationSuccessEventSubscriber.php @@ -29,7 +29,7 @@ public function onAuthenticationSuccess(AuthenticationSuccessEvent $event): void { $user = $event->getUser(); - if (!($user instanceof User)) { + if (!$user instanceof User) { return; } diff --git a/lib/RoadizCoreBundle/src/EventSubscriber/ReverseProxyCacheEventSubscriber.php b/lib/RoadizCoreBundle/src/EventSubscriber/ReverseProxyCacheEventSubscriber.php index 72913c3eb..8faa1ee33 100644 --- a/lib/RoadizCoreBundle/src/EventSubscriber/ReverseProxyCacheEventSubscriber.php +++ b/lib/RoadizCoreBundle/src/EventSubscriber/ReverseProxyCacheEventSubscriber.php @@ -38,7 +38,7 @@ public static function getSubscribedEvents(): array ]; } - protected function supportConfig(): bool + private function supportConfig(): bool { return count($this->reverseProxyCacheLocator->getFrontends()) > 0; } @@ -84,7 +84,7 @@ public function onPurgeRequest(NodesSourcesUpdatedEvent $event): void /** * @return HttpRequestMessageInterface[] */ - protected function createBanRequests(): array + private function createBanRequests(): array { $requests = []; foreach ($this->reverseProxyCacheLocator->getFrontends() as $frontend) { @@ -110,7 +110,7 @@ protected function createBanRequests(): array return $requests; } - protected function purgeNodesSources(NodesSources $nodeSource): void + private function purgeNodesSources(NodesSources $nodeSource): void { try { $this->bus->dispatch(new Envelope(new PurgeReverseProxyCacheMessage($nodeSource->getId()))); @@ -119,7 +119,7 @@ protected function purgeNodesSources(NodesSources $nodeSource): void } } - protected function sendRequest(HttpRequestMessageInterface $requestMessage): void + private function sendRequest(HttpRequestMessageInterface $requestMessage): void { try { $this->bus->dispatch(new Envelope($requestMessage)); diff --git a/lib/RoadizCoreBundle/src/Form/CaptchaType.php b/lib/RoadizCoreBundle/src/Form/CaptchaType.php index 748aa7926..200dba970 100644 --- a/lib/RoadizCoreBundle/src/Form/CaptchaType.php +++ b/lib/RoadizCoreBundle/src/Form/CaptchaType.php @@ -20,7 +20,7 @@ public function __construct( } /** - * @see \Symfony\Component\Form\AbstractType::buildView() + * @see AbstractType::buildView() */ #[\Override] public function buildView(FormView $view, FormInterface $form, array $options): void @@ -29,7 +29,7 @@ public function buildView(FormView $view, FormInterface $form, array $options): } /** - * @see \Symfony\Component\Form\AbstractType::configureOptions() + * @see AbstractType::configureOptions() */ #[\Override] public function configureOptions(OptionsResolver $resolver): void diff --git a/lib/RoadizCoreBundle/src/Form/Constraint/CaptchaValidator.php b/lib/RoadizCoreBundle/src/Form/Constraint/CaptchaValidator.php index 0f010f34e..e7cf3b8b4 100644 --- a/lib/RoadizCoreBundle/src/Form/Constraint/CaptchaValidator.php +++ b/lib/RoadizCoreBundle/src/Form/Constraint/CaptchaValidator.php @@ -18,7 +18,7 @@ public function __construct( } /** - * @see \Symfony\Component\Validator\ConstraintValidator::validate() + * @see ConstraintValidator::validate() */ #[\Override] public function validate(mixed $data, Constraint $constraint): void diff --git a/lib/RoadizCoreBundle/src/Form/DataTransformer/ExplorerProviderItemTransformer.php b/lib/RoadizCoreBundle/src/Form/DataTransformer/ExplorerProviderItemTransformer.php index edcae31be..a0e3b84f0 100644 --- a/lib/RoadizCoreBundle/src/Form/DataTransformer/ExplorerProviderItemTransformer.php +++ b/lib/RoadizCoreBundle/src/Form/DataTransformer/ExplorerProviderItemTransformer.php @@ -13,9 +13,9 @@ final readonly class ExplorerProviderItemTransformer implements DataTransformerInterface { public function __construct( - protected ExplorerProviderInterface $explorerProvider, - protected bool $multiple = true, - protected bool $useCollection = false, + private ExplorerProviderInterface $explorerProvider, + private bool $multiple = true, + private bool $useCollection = false, ) { } diff --git a/lib/RoadizCoreBundle/src/Form/DataTransformer/TranslationTransformer.php b/lib/RoadizCoreBundle/src/Form/DataTransformer/TranslationTransformer.php index cb7e67066..9d1543d2e 100644 --- a/lib/RoadizCoreBundle/src/Form/DataTransformer/TranslationTransformer.php +++ b/lib/RoadizCoreBundle/src/Form/DataTransformer/TranslationTransformer.php @@ -22,7 +22,7 @@ public function __construct(private ManagerRegistry $managerRegistry) #[\Override] public function transform(mixed $value): int|string|null { - if (!($value instanceof PersistableInterface)) { + if (!$value instanceof PersistableInterface) { return null; } diff --git a/lib/RoadizCoreBundle/src/Form/NodeTypeFieldsType.php b/lib/RoadizCoreBundle/src/Form/NodeTypeFieldsType.php index c2654900e..b720cc858 100644 --- a/lib/RoadizCoreBundle/src/Form/NodeTypeFieldsType.php +++ b/lib/RoadizCoreBundle/src/Form/NodeTypeFieldsType.php @@ -31,17 +31,16 @@ public function configureOptions(OptionsResolver $resolver): void $resolver->setNormalizer('choices', function (Options $options) { if (null !== $options['nodeType']) { return $options['nodeType']->getFields(); - } else { - $nodeTypeFields = []; - foreach ($this->nodeTypesBag->all() as $nodeType) { - $nodeTypeFields = [ - ...$nodeTypeFields, - ...$nodeType->getFields()->toArray(), - ]; - } - - return $nodeTypeFields; } + $nodeTypeFields = []; + foreach ($this->nodeTypesBag->all() as $nodeType) { + $nodeTypeFields = [ + ...$nodeTypeFields, + ...$nodeType->getFields()->toArray(), + ]; + } + + return $nodeTypeFields; }); } diff --git a/lib/RoadizCoreBundle/src/Form/NodeTypesType.php b/lib/RoadizCoreBundle/src/Form/NodeTypesType.php index a19e69f91..fab2b76ee 100644 --- a/lib/RoadizCoreBundle/src/Form/NodeTypesType.php +++ b/lib/RoadizCoreBundle/src/Form/NodeTypesType.php @@ -50,9 +50,9 @@ public function configureOptions(OptionsResolver $resolver): void } if ($nodeType->isReachable()) { return 'reachable'; - } else { - return 'not_reachable'; } + + return 'not_reachable'; } return null; diff --git a/lib/RoadizCoreBundle/src/ListManager/EntityListManager.php b/lib/RoadizCoreBundle/src/ListManager/EntityListManager.php index b1757b958..16ee2be5a 100644 --- a/lib/RoadizCoreBundle/src/ListManager/EntityListManager.php +++ b/lib/RoadizCoreBundle/src/ListManager/EntityListManager.php @@ -209,18 +209,17 @@ public function getEntities(): array $this->paginator->setItemsPerPage($this->getItemPerPage()); return $this->paginator->findByAtPage($this->orderingArray, $this->currentPage); - } else { - $repository = $this->entityManager->getRepository($this->entityName); - if ($repository instanceof StatusAwareRepository) { - $repository->setDisplayingNotPublishedNodes($this->isDisplayingNotPublishedNodes()); - $repository->setDisplayingAllNodesStatuses($this->isDisplayingAllNodesStatuses()); - } - - return $repository->findBy( - $this->filteringArray, - $this->orderingArray, - $this->itemPerPage - ); } + $repository = $this->entityManager->getRepository($this->entityName); + if ($repository instanceof StatusAwareRepository) { + $repository->setDisplayingNotPublishedNodes($this->isDisplayingNotPublishedNodes()); + $repository->setDisplayingAllNodesStatuses($this->isDisplayingAllNodesStatuses()); + } + + return $repository->findBy( + $this->filteringArray, + $this->orderingArray, + $this->itemPerPage + ); } } diff --git a/lib/RoadizCoreBundle/src/ListManager/NodePaginator.php b/lib/RoadizCoreBundle/src/ListManager/NodePaginator.php index 7f891e700..b38f510f7 100644 --- a/lib/RoadizCoreBundle/src/ListManager/NodePaginator.php +++ b/lib/RoadizCoreBundle/src/ListManager/NodePaginator.php @@ -38,26 +38,25 @@ public function findByAtPage(array $order = [], int $page = 1): array { if (null !== $this->searchPattern) { return $this->searchByAtPage($order, $page); - } else { - /** @var NodeRepository $repository */ - $repository = $this->getRepository(); - if ($repository instanceof NodeRepository) { - return $repository->findBy( - $this->criteria, - $order, - $this->getItemsPerPage(), - $this->getItemsPerPage() * ($page - 1), - $this->getTranslation() - ); - } - + } + /** @var NodeRepository $repository */ + $repository = $this->getRepository(); + if ($repository instanceof NodeRepository) { return $repository->findBy( $this->criteria, $order, $this->getItemsPerPage(), - $this->getItemsPerPage() * ($page - 1) + $this->getItemsPerPage() * ($page - 1), + $this->getTranslation() ); } + + return $repository->findBy( + $this->criteria, + $order, + $this->getItemsPerPage(), + $this->getItemsPerPage() * ($page - 1) + ); } #[\Override] diff --git a/lib/RoadizCoreBundle/src/ListManager/NodeTreeDtoListManager.php b/lib/RoadizCoreBundle/src/ListManager/NodeTreeDtoListManager.php index 94ec24dd6..e800fadc3 100644 --- a/lib/RoadizCoreBundle/src/ListManager/NodeTreeDtoListManager.php +++ b/lib/RoadizCoreBundle/src/ListManager/NodeTreeDtoListManager.php @@ -37,18 +37,17 @@ public function getEntities(): array // @phpstan-ignore-next-line return $this->paginator->findByAtPage($this->orderingArray, $this->currentPage); - } else { - $repository = $this->entityManager->getRepository(Node::class); - if ($repository instanceof StatusAwareRepository) { - $repository->setDisplayingNotPublishedNodes($this->isDisplayingNotPublishedNodes()); - $repository->setDisplayingAllNodesStatuses($this->isDisplayingAllNodesStatuses()); - } - - return $repository->findByAsNodeTreeDto( - $this->filteringArray, - $this->orderingArray, - $this->itemPerPage - ); } + $repository = $this->entityManager->getRepository(Node::class); + if ($repository instanceof StatusAwareRepository) { + $repository->setDisplayingNotPublishedNodes($this->isDisplayingNotPublishedNodes()); + $repository->setDisplayingAllNodesStatuses($this->isDisplayingAllNodesStatuses()); + } + + return $repository->findByAsNodeTreeDto( + $this->filteringArray, + $this->orderingArray, + $this->itemPerPage + ); } } diff --git a/lib/RoadizCoreBundle/src/ListManager/NodeTreeDtoPaginator.php b/lib/RoadizCoreBundle/src/ListManager/NodeTreeDtoPaginator.php index f1be95bdf..018d737b9 100644 --- a/lib/RoadizCoreBundle/src/ListManager/NodeTreeDtoPaginator.php +++ b/lib/RoadizCoreBundle/src/ListManager/NodeTreeDtoPaginator.php @@ -47,15 +47,15 @@ public function findByAtPage(array $order = [], int $page = 1): array $this->getItemsPerPage(), $this->getItemsPerPage() * ($page - 1) ); - } else { - return $repository->findByAsNodeTreeDto( - $this->criteria, - $order, - $this->getItemsPerPage(), - $this->getItemsPerPage() * ($page - 1), - $this->getTranslation() - ); } + + return $repository->findByAsNodeTreeDto( + $this->criteria, + $order, + $this->getItemsPerPage(), + $this->getItemsPerPage() * ($page - 1), + $this->getTranslation() + ); } #[\Override] diff --git a/lib/RoadizCoreBundle/src/ListManager/NodesSourcesPaginator.php b/lib/RoadizCoreBundle/src/ListManager/NodesSourcesPaginator.php index 74da384b7..797376cd4 100644 --- a/lib/RoadizCoreBundle/src/ListManager/NodesSourcesPaginator.php +++ b/lib/RoadizCoreBundle/src/ListManager/NodesSourcesPaginator.php @@ -37,14 +37,14 @@ public function findByAtPage(array $order = [], int $page = 1): array { if (null !== $this->searchPattern) { return $this->searchByAtPage($order, $page); - } else { - return $this->getRepository()->findBy( - $this->criteria, - $order, - $this->getItemsPerPage(), - $this->getItemsPerPage() * ($page - 1) - ); } + + return $this->getRepository()->findBy( + $this->criteria, + $order, + $this->getItemsPerPage(), + $this->getItemsPerPage() * ($page - 1) + ); } #[\Override] diff --git a/lib/RoadizCoreBundle/src/ListManager/Paginator.php b/lib/RoadizCoreBundle/src/ListManager/Paginator.php index 2b0affecf..715c6d4a7 100644 --- a/lib/RoadizCoreBundle/src/ListManager/Paginator.php +++ b/lib/RoadizCoreBundle/src/ListManager/Paginator.php @@ -144,15 +144,15 @@ public function findByAtPage(array $order = [], int $page = 1): array { if (null !== $this->searchPattern) { return $this->searchByAtPage($order, $page); - } else { - return $this->getRepository() - ->findBy( - $this->criteria, - $order, - $this->getItemsPerPage(), - $this->getItemsPerPage() * ($page - 1) - ); } + + return $this->getRepository() + ->findBy( + $this->criteria, + $order, + $this->getItemsPerPage(), + $this->getItemsPerPage() * ($page - 1) + ); } /** @@ -228,7 +228,7 @@ protected function getSearchQueryBuilder(string $alias): QueryBuilder protected function getSearchableFields(): array { $metadata = $this->em->getClassMetadata($this->entityName); - if (!($metadata instanceof ClassMetadataInfo)) { + if (!$metadata instanceof ClassMetadataInfo) { throw new \RuntimeException('Entity has no metadata.'); } diff --git a/lib/RoadizCoreBundle/src/ListManager/TagListManager.php b/lib/RoadizCoreBundle/src/ListManager/TagListManager.php index 4cd4d2c41..255b8e88e 100644 --- a/lib/RoadizCoreBundle/src/ListManager/TagListManager.php +++ b/lib/RoadizCoreBundle/src/ListManager/TagListManager.php @@ -38,9 +38,9 @@ public function getEntities(): array return $this->entityManager ->getRepository(TagTranslation::class) ->searchBy($this->searchPattern, $this->filteringArray, $this->orderingArray); - } else { - return $this->paginator->findByAtPage($this->filteringArray, $this->currentPage); } + + return $this->paginator->findByAtPage($this->filteringArray, $this->currentPage); } catch (\Exception) { return []; } diff --git a/lib/RoadizCoreBundle/src/Logger/Entity/Log.php b/lib/RoadizCoreBundle/src/Logger/Entity/Log.php index 23cf6384b..a789aba21 100644 --- a/lib/RoadizCoreBundle/src/Logger/Entity/Log.php +++ b/lib/RoadizCoreBundle/src/Logger/Entity/Log.php @@ -14,8 +14,7 @@ use Symfony\Component\Uid\Uuid; use Symfony\Component\Validator\Constraints as Assert; -#[ - ORM\Entity(repositoryClass: LogRepository::class), +#[ORM\Entity(repositoryClass: LogRepository::class), ORM\Table(name: 'log'), ORM\Index(columns: ['datetime']), ORM\Index(columns: ['entity_class']), @@ -29,8 +28,7 @@ ORM\Index(columns: ['level']), ORM\Index(columns: ['username']), ORM\Index(columns: ['channel']), - ORM\HasLifecycleCallbacks -] + ORM\HasLifecycleCallbacks] class Log implements PersistableInterface { use SequentialIdTrait; diff --git a/lib/RoadizCoreBundle/src/Mailer/ContactFormManager.php b/lib/RoadizCoreBundle/src/Mailer/ContactFormManager.php index 2ad93145c..c996a6e3f 100644 --- a/lib/RoadizCoreBundle/src/Mailer/ContactFormManager.php +++ b/lib/RoadizCoreBundle/src/Mailer/ContactFormManager.php @@ -267,18 +267,17 @@ public function handle(?callable $onValid = null): ?Response ); if ($returnJson) { return new JsonResponse([], Response::HTTP_ACCEPTED); - } else { - if ($request->hasPreviousSession()) { - /** @var Session $session */ - $session = $request->getSession(); - $session->getFlashBag() - ->add('confirm', $this->translator->trans('form.successfully.sent')); - } + } + if ($request->hasPreviousSession()) { + /** @var Session $session */ + $session = $request->getSession(); + $session->getFlashBag() + ->add('confirm', $this->translator->trans('form.successfully.sent')); + } - $this->redirectUrl ??= $request->getUri(); + $this->redirectUrl ??= $request->getUri(); - return new RedirectResponse($this->redirectUrl); - } + return new RedirectResponse($this->redirectUrl); } catch (BadFormRequestException $e) { if (null !== $e->getFieldErrored() && $this->form->has($e->getFieldErrored())) { $this->form->get($e->getFieldErrored())->addError(new FormError($e->getMessage())); @@ -318,16 +317,16 @@ public function handle(?callable $onValid = null): ?Response /** * @return array */ - protected function getRecipients(): array + private function getRecipients(): array { if (!empty($this->recipients)) { return $this->recipients; } elseif ($this->notifier instanceof Notifier) { return $this->notifier->getAdminRecipients(); - } else { - // Fallback to the parent method if Notifier is not used - return []; } + + // Fallback to the parent method if Notifier is not used + return []; } /** @@ -352,7 +351,7 @@ public function setRecipients(?array $recipients): ContactFormManager * * @throws BadFormRequestException */ - protected function handleFiles(): array + private function handleFiles(): array { $uploadedFiles = []; $request = $this->requestStack->getMainRequest(); @@ -402,7 +401,7 @@ protected function handleFiles(): array * * @throws BadFormRequestException */ - protected function addUploadedFile(array &$uploadedFiles, string $name, UploadedFile $uploadedFile): ContactFormManager + private function addUploadedFile(array &$uploadedFiles, string $name, UploadedFile $uploadedFile): ContactFormManager { if ( !$uploadedFile->isValid() @@ -410,14 +409,13 @@ protected function addUploadedFile(array &$uploadedFiles, string $name, Uploaded || $uploadedFile->getSize() > $this->maxFileSize ) { throw new BadFormRequestException($this->translator->trans('file.not.accepted'), Response::HTTP_FORBIDDEN, 'danger', $name); - } else { - $uploadedFiles[$name] = $uploadedFile; } + $uploadedFiles[$name] = $uploadedFile; return $this; } - protected function findEmailData(array $formData): ?string + private function findEmailData(array $formData): ?string { foreach ($formData as $key => $value) { if ( @@ -439,7 +437,7 @@ protected function findEmailData(array $formData): ?string * * @throws \Exception */ - protected function createNotificationFromForm(FormInterface $form, array $uploadedFiles): ContactFormNotification + private function createNotificationFromForm(FormInterface $form, array $uploadedFiles): ContactFormNotification { $formData = $form->getData(); $fields = $this->flattenFormData($form, []); @@ -528,7 +526,7 @@ public function setEmailType(string $emailType): ContactFormManager return $this; } - protected function isFieldPrivate(FormInterface $form): bool + private function isFieldPrivate(FormInterface $form): bool { $key = $form->getName(); $privateFieldNames = [ @@ -541,7 +539,7 @@ protected function isFieldPrivate(FormInterface $form): bool ; } - protected function flattenFormData(FormInterface $form, array $fields): array + private function flattenFormData(FormInterface $form, array $fields): array { /** @var FormInterface $formItem */ foreach ($form as $formItem) { diff --git a/lib/RoadizCoreBundle/src/Message/Handler/PurgeReverseProxyCacheMessageHandler.php b/lib/RoadizCoreBundle/src/Message/Handler/PurgeReverseProxyCacheMessageHandler.php index 86531c884..7b379eb5a 100644 --- a/lib/RoadizCoreBundle/src/Message/Handler/PurgeReverseProxyCacheMessageHandler.php +++ b/lib/RoadizCoreBundle/src/Message/Handler/PurgeReverseProxyCacheMessageHandler.php @@ -57,7 +57,7 @@ public function __invoke(PurgeReverseProxyCacheMessage $message): void /** * @return HttpRequestMessageInterface[] */ - protected function createPurgeRequests(string $path = '/'): array + private function createPurgeRequests(string $path = '/'): array { $requests = []; foreach ($this->reverseProxyCacheLocator->getFrontends() as $frontend) { @@ -78,7 +78,7 @@ protected function createPurgeRequests(string $path = '/'): array return $requests; } - protected function sendRequest(HttpRequestMessageInterface $requestMessage): void + private function sendRequest(HttpRequestMessageInterface $requestMessage): void { try { $this->bus->dispatch(new Envelope($requestMessage)); diff --git a/lib/RoadizCoreBundle/src/Model/AttributeGroupTrait.php b/lib/RoadizCoreBundle/src/Model/AttributeGroupTrait.php index e0fd2f332..8a5e48f09 100644 --- a/lib/RoadizCoreBundle/src/Model/AttributeGroupTrait.php +++ b/lib/RoadizCoreBundle/src/Model/AttributeGroupTrait.php @@ -13,36 +13,30 @@ trait AttributeGroupTrait { - #[ - ORM\Column(name: 'canonical_name', type: 'string', length: 255, unique: true, nullable: false), + #[ORM\Column(name: 'canonical_name', type: 'string', length: 255, unique: true, nullable: false), Serializer\Groups(['attribute_group', 'attribute:export', 'attribute:import', 'attribute', 'node', 'nodes_sources']), Assert\NotNull(), Assert\Length(max: 255), - Assert\NotBlank() - ] + Assert\NotBlank()] protected string $canonicalName = ''; /** * @var Collection */ - #[ - ORM\OneToMany(mappedBy: 'group', targetEntity: AttributeInterface::class), - Serializer\Ignore(), - ] + #[ORM\OneToMany(mappedBy: 'group', targetEntity: AttributeInterface::class), + Serializer\Ignore(),] protected Collection $attributes; /** * @var Collection */ - #[ - ORM\OneToMany( - mappedBy: 'attributeGroup', - targetEntity: AttributeGroupTranslationInterface::class, - cascade: ['all'], - orphanRemoval: true - ), - Serializer\Groups(['attribute_group', 'attribute:export', 'attribute', 'node', 'nodes_sources']), - ] + #[ORM\OneToMany( + mappedBy: 'attributeGroup', + targetEntity: AttributeGroupTranslationInterface::class, + cascade: ['all'], + orphanRemoval: true + ), + Serializer\Groups(['attribute_group', 'attribute:export', 'attribute', 'node', 'nodes_sources']),] protected Collection $attributeGroupTranslations; public function getName(): ?string diff --git a/lib/RoadizCoreBundle/src/Model/AttributeGroupTranslationTrait.php b/lib/RoadizCoreBundle/src/Model/AttributeGroupTranslationTrait.php index d5c2293bc..ccca7c40d 100644 --- a/lib/RoadizCoreBundle/src/Model/AttributeGroupTranslationTrait.php +++ b/lib/RoadizCoreBundle/src/Model/AttributeGroupTranslationTrait.php @@ -11,25 +11,19 @@ trait AttributeGroupTranslationTrait { - #[ - ORM\ManyToOne(targetEntity: TranslationInterface::class), + #[ORM\ManyToOne(targetEntity: TranslationInterface::class), ORM\JoinColumn(name: 'translation_id', referencedColumnName: 'id', nullable: false, onDelete: 'CASCADE'), - Serializer\Groups(['attribute_group', 'attribute', 'attribute:export', 'node', 'nodes_sources']), - ] + Serializer\Groups(['attribute_group', 'attribute', 'attribute:export', 'node', 'nodes_sources']),] protected TranslationInterface $translation; - #[ - ORM\Column(type: 'string', length: 255, unique: false, nullable: false), + #[ORM\Column(type: 'string', length: 255, unique: false, nullable: false), Serializer\Groups(['attribute_group', 'attribute:export', 'attribute', 'node', 'nodes_sources']), - Assert\Length(max: 255) - ] + Assert\Length(max: 255)] protected string $name = ''; - #[ - ORM\ManyToOne(targetEntity: AttributeGroupInterface::class, cascade: ['persist'], inversedBy: 'attributeGroupTranslations'), + #[ORM\ManyToOne(targetEntity: AttributeGroupInterface::class, cascade: ['persist'], inversedBy: 'attributeGroupTranslations'), ORM\JoinColumn(name: 'attribute_group_id', referencedColumnName: 'id', nullable: false, onDelete: 'CASCADE'), - Serializer\Ignore - ] + Serializer\Ignore] protected AttributeGroupInterface $attributeGroup; public function getName(): string diff --git a/lib/RoadizCoreBundle/src/Model/AttributeTrait.php b/lib/RoadizCoreBundle/src/Model/AttributeTrait.php index 4eb216167..8a68c2bbb 100644 --- a/lib/RoadizCoreBundle/src/Model/AttributeTrait.php +++ b/lib/RoadizCoreBundle/src/Model/AttributeTrait.php @@ -13,74 +13,60 @@ trait AttributeTrait { - #[ - ORM\Column(type: 'string', length: 255, unique: true, nullable: false), + #[ORM\Column(type: 'string', length: 255, unique: true, nullable: false), Serializer\Groups(['attribute', 'attribute:export', 'attribute:import', 'node', 'nodes_sources']), Assert\NotNull(), Assert\NotBlank(), - Assert\Length(max: 255) - ] + Assert\Length(max: 255)] protected string $code = ''; - #[ - ORM\Column(type: 'boolean', unique: false, nullable: false, options: ['default' => false]), - Serializer\Groups(['attribute', 'attribute:export', 'attribute:import']), - ] + #[ORM\Column(type: 'boolean', unique: false, nullable: false, options: ['default' => false]), + Serializer\Groups(['attribute', 'attribute:export', 'attribute:import']),] protected bool $searchable = false; - #[ - ORM\Column(type: 'integer', unique: false, nullable: false), - Serializer\Groups(['attribute', 'attribute:export', 'attribute:import']), - ] + #[ORM\Column(type: 'integer', unique: false, nullable: false), + Serializer\Groups(['attribute', 'attribute:export', 'attribute:import']),] protected int $type = AttributeInterface::STRING_T; - #[ - ORM\Column(type: 'string', length: 7, unique: false, nullable: true), + #[ORM\Column(type: 'string', length: 7, unique: false, nullable: true), Serializer\Groups(['attribute', 'node', 'nodes_sources', 'attribute:export', 'attribute:import']), - Assert\Length(max: 7) - ] + Assert\Length(max: 7)] protected ?string $color = null; - #[ - ORM\ManyToOne( - targetEntity: AttributeGroupInterface::class, - cascade: ['persist', 'merge'], - fetch: 'EAGER', - inversedBy: 'attributes' - ), + #[ORM\ManyToOne( + targetEntity: AttributeGroupInterface::class, + cascade: ['persist', 'merge'], + fetch: 'EAGER', + inversedBy: 'attributes' + ), ORM\JoinColumn(name: 'group_id', onDelete: 'SET NULL'), - Serializer\Groups(['attribute', 'node', 'nodes_sources', 'attribute:export', 'attribute:import']), - ] + Serializer\Groups(['attribute', 'node', 'nodes_sources', 'attribute:export', 'attribute:import']),] protected ?AttributeGroupInterface $group = null; /** * @var Collection */ - #[ - ORM\OneToMany( - mappedBy: 'attribute', - targetEntity: AttributeTranslationInterface::class, - cascade: ['all'], - fetch: 'EAGER', - orphanRemoval: true - ), - Serializer\Groups(['attribute', 'node', 'nodes_sources', 'attribute:export']), - ] + #[ORM\OneToMany( + mappedBy: 'attribute', + targetEntity: AttributeTranslationInterface::class, + cascade: ['all'], + fetch: 'EAGER', + orphanRemoval: true + ), + Serializer\Groups(['attribute', 'node', 'nodes_sources', 'attribute:export']),] protected Collection $attributeTranslations; /** * @var Collection */ - #[ - ORM\OneToMany( - mappedBy: 'attribute', - targetEntity: AttributeValueInterface::class, - cascade: ['persist', 'remove'], - fetch: 'EXTRA_LAZY', - orphanRemoval: true - ), - Serializer\Ignore - ] + #[ORM\OneToMany( + mappedBy: 'attribute', + targetEntity: AttributeValueInterface::class, + cascade: ['persist', 'remove'], + fetch: 'EXTRA_LAZY', + orphanRemoval: true + ), + Serializer\Ignore] protected Collection $attributeValues; public function getCode(): string diff --git a/lib/RoadizCoreBundle/src/Model/AttributeTranslationTrait.php b/lib/RoadizCoreBundle/src/Model/AttributeTranslationTrait.php index c55eac74e..f651b3b3f 100644 --- a/lib/RoadizCoreBundle/src/Model/AttributeTranslationTrait.php +++ b/lib/RoadizCoreBundle/src/Model/AttributeTranslationTrait.php @@ -11,34 +11,26 @@ trait AttributeTranslationTrait { - #[ - ORM\ManyToOne(targetEntity: TranslationInterface::class), + #[ORM\ManyToOne(targetEntity: TranslationInterface::class), ORM\JoinColumn(name: 'translation_id', referencedColumnName: 'id', nullable: false, onDelete: 'CASCADE'), - Serializer\Groups(['attribute', 'attribute:export', 'node', 'nodes_sources']), - ] + Serializer\Groups(['attribute', 'attribute:export', 'node', 'nodes_sources']),] protected TranslationInterface $translation; - #[ - ORM\Column(type: 'string', length: 250, unique: false, nullable: false), + #[ORM\Column(type: 'string', length: 250, unique: false, nullable: false), Serializer\Groups(['attribute', 'attribute:export', 'node', 'nodes_sources']), - Assert\Length(max: 250) - ] + Assert\Length(max: 250)] protected string $label = ''; /** * @var array|null */ - #[ - ORM\Column(type: 'simple_array', unique: false, nullable: true), - Serializer\Groups(['attribute', 'attribute:export']), - ] + #[ORM\Column(type: 'simple_array', unique: false, nullable: true), + Serializer\Groups(['attribute', 'attribute:export']),] protected ?array $options = []; - #[ - ORM\ManyToOne(targetEntity: AttributeInterface::class, cascade: ['persist'], inversedBy: 'attributeTranslations'), + #[ORM\ManyToOne(targetEntity: AttributeInterface::class, cascade: ['persist'], inversedBy: 'attributeTranslations'), ORM\JoinColumn(name: 'attribute_id', referencedColumnName: 'id', nullable: false, onDelete: 'CASCADE'), - Serializer\Ignore, - ] + Serializer\Ignore,] protected AttributeInterface $attribute; public function getLabel(): ?string diff --git a/lib/RoadizCoreBundle/src/Model/AttributeValueTrait.php b/lib/RoadizCoreBundle/src/Model/AttributeValueTrait.php index d6e42d5f7..b967087de 100644 --- a/lib/RoadizCoreBundle/src/Model/AttributeValueTrait.php +++ b/lib/RoadizCoreBundle/src/Model/AttributeValueTrait.php @@ -13,8 +13,7 @@ trait AttributeValueTrait { - #[ - ORM\ManyToOne(targetEntity: AttributeInterface::class, fetch: 'EAGER', inversedBy: 'attributeValues'), + #[ORM\ManyToOne(targetEntity: AttributeInterface::class, fetch: 'EAGER', inversedBy: 'attributeValues'), ORM\JoinColumn(name: 'attribute_id', referencedColumnName: 'id', nullable: false, onDelete: 'CASCADE'), Serializer\Groups(['attribute', 'node', 'nodes_sources']), ApiFilter(BaseFilter\SearchFilter::class, properties: [ @@ -35,21 +34,19 @@ trait AttributeValueTrait ]), ApiFilter(BaseFilter\OrderFilter::class, properties: [ 'attribute.weight' => 'DESC', - ]) - ] + ])] protected AttributeInterface $attribute; /** * @var Collection */ - #[ - ORM\OneToMany( - mappedBy: 'attributeValue', - targetEntity: AttributeValueTranslationInterface::class, - cascade: ['persist', 'remove'], - fetch: 'EAGER', - orphanRemoval: true - ), + #[ORM\OneToMany( + mappedBy: 'attributeValue', + targetEntity: AttributeValueTranslationInterface::class, + cascade: ['persist', 'remove'], + fetch: 'EAGER', + orphanRemoval: true + ), Serializer\Groups(['attribute', 'node', 'nodes_sources']), ApiFilter(BaseFilter\SearchFilter::class, properties: [ 'attributeValueTranslations.value' => 'partial', @@ -59,8 +56,7 @@ trait AttributeValueTrait ]), ApiFilter(BaseFilter\ExistsFilter::class, properties: [ 'attributeValueTranslations.value', - ]), - ] + ]),] protected Collection $attributeValueTranslations; public function getAttribute(): ?AttributeInterface diff --git a/lib/RoadizCoreBundle/src/Model/AttributeValueTranslationTrait.php b/lib/RoadizCoreBundle/src/Model/AttributeValueTranslationTrait.php index 1abb7700d..a6c2dbcdf 100644 --- a/lib/RoadizCoreBundle/src/Model/AttributeValueTranslationTrait.php +++ b/lib/RoadizCoreBundle/src/Model/AttributeValueTranslationTrait.php @@ -11,25 +11,19 @@ trait AttributeValueTranslationTrait { - #[ - ORM\ManyToOne(targetEntity: TranslationInterface::class), + #[ORM\ManyToOne(targetEntity: TranslationInterface::class), ORM\JoinColumn(name: 'translation_id', referencedColumnName: 'id', nullable: false, onDelete: 'CASCADE'), - Serializer\Groups(['attribute', 'node', 'nodes_sources']), - ] + Serializer\Groups(['attribute', 'node', 'nodes_sources']),] protected TranslationInterface $translation; - #[ - ORM\Column(type: 'string', length: 255, unique: false, nullable: true), + #[ORM\Column(type: 'string', length: 255, unique: false, nullable: true), Serializer\Groups(['attribute', 'node', 'nodes_sources']), - Assert\Length(max: 255) - ] + Assert\Length(max: 255)] protected ?string $value = null; - #[ - ORM\ManyToOne(targetEntity: AttributeValueInterface::class, cascade: ['persist'], inversedBy: 'attributeValueTranslations'), + #[ORM\ManyToOne(targetEntity: AttributeValueInterface::class, cascade: ['persist'], inversedBy: 'attributeValueTranslations'), ORM\JoinColumn(name: 'attribute_value', referencedColumnName: 'id', nullable: false, onDelete: 'CASCADE'), - Serializer\Ignore - ] + Serializer\Ignore] protected AttributeValueInterface $attributeValue; /** diff --git a/lib/RoadizCoreBundle/src/Model/DocumentDto.php b/lib/RoadizCoreBundle/src/Model/DocumentDto.php index b2ff4f918..f7ca81975 100644 --- a/lib/RoadizCoreBundle/src/Model/DocumentDto.php +++ b/lib/RoadizCoreBundle/src/Model/DocumentDto.php @@ -123,14 +123,12 @@ public function getDocumentTranslationExternalUrl(): ?string return $this->documentTranslationExternalUrl; } - #[ - Groups(['document', 'document_display', 'nodes_sources', 'tag', 'attribute']), + #[Groups(['document', 'document_display', 'nodes_sources', 'tag', 'attribute']), SerializedName('alt'), ApiProperty( description: 'Document alternative text, for img HTML tag. Returns NULL if image is decorative (alt="").', writable: false, - ) - ] + )] #[\Override] public function getAlternativeText(): ?string { @@ -144,9 +142,9 @@ public function getImageCropAlignment(): ?string { if (!empty($this->nodeSourceDocumentImageCropAlignment)) { return $this->nodeSourceDocumentImageCropAlignment; - } else { - return !empty($this->documentImageCropAlignment) ? $this->documentImageCropAlignment : null; } + + return !empty($this->documentImageCropAlignment) ? $this->documentImageCropAlignment : null; } #[Groups(['document', 'document_display', 'nodes_sources', 'tag', 'attribute'])] @@ -154,9 +152,9 @@ public function getHotspot(): ?array { if (null !== $this->nodeSourceDocumentHotspot) { return $this->nodeSourceDocumentHotspot; - } else { - return $this->documentHotspot; } + + return $this->documentHotspot; } /* diff --git a/lib/RoadizCoreBundle/src/Node/NodeMover.php b/lib/RoadizCoreBundle/src/Node/NodeMover.php index 9dbda8cda..215d3bcde 100644 --- a/lib/RoadizCoreBundle/src/Node/NodeMover.php +++ b/lib/RoadizCoreBundle/src/Node/NodeMover.php @@ -125,7 +125,7 @@ public function redirectAll(Node $node, array $previousPaths, bool $permanently /** * Warning: this method DOES NOT flush entity manager. */ - protected function redirect(NodesSources $nodeSource, string $previousPath, bool $permanently = true): NodesSources + private function redirect(NodesSources $nodeSource, string $previousPath, bool $permanently = true): NodesSources { if (empty($previousPath) || '/' === $previousPath) { $this->logger->warning('Cannot redirect empty or root path: '.$nodeSource->getTitle()); diff --git a/lib/RoadizCoreBundle/src/Node/NodeTranslator.php b/lib/RoadizCoreBundle/src/Node/NodeTranslator.php index 9d77dbe6e..3672509b8 100644 --- a/lib/RoadizCoreBundle/src/Node/NodeTranslator.php +++ b/lib/RoadizCoreBundle/src/Node/NodeTranslator.php @@ -54,7 +54,7 @@ private function translateSingleNode( $node->getNodeSources()->filter(fn (NodesSources $nodesSources) => $nodesSources->getTranslation()->isDefaultTranslation())->first() ?: $node->getNodeSources()->first(); - if (!($baseSource instanceof NodesSources)) { + if (!$baseSource instanceof NodesSources) { throw new \RuntimeException('Cannot translate a Node without any NodesSources'); } $source = clone $baseSource; @@ -72,8 +72,8 @@ private function translateSingleNode( $this->dispatcher->dispatch(new NodesSourcesCreatedEvent($source)); return $source; - } else { - return $existing; } + + return $existing; } } diff --git a/lib/RoadizCoreBundle/src/Node/NodeTranstyper.php b/lib/RoadizCoreBundle/src/Node/NodeTranstyper.php index 296b876bf..75976d2ce 100644 --- a/lib/RoadizCoreBundle/src/Node/NodeTranstyper.php +++ b/lib/RoadizCoreBundle/src/Node/NodeTranstyper.php @@ -127,7 +127,7 @@ public function transtype(Node $node, NodeTypeInterface $destinationNodeType, bo return $node; } - protected function removeOldSources(Node $node, array &$sources): void + private function removeOldSources(Node $node, array &$sources): void { /** @var NodesSources $existingSource */ foreach ($sources as $existingSource) { @@ -145,7 +145,7 @@ protected function removeOldSources(Node $node, array &$sources): void * * @param class-string $sourceClass */ - protected function doTranstypeSingleSource( + private function doTranstypeSingleSource( Node $node, NodesSources $existingSource, TranslationInterface $translation, @@ -221,7 +221,7 @@ protected function doTranstypeSingleSource( * * @throws \InvalidArgumentException if mock fails due to Source class not existing */ - protected function mockTranstype(NodeTypeInterface $nodeType): void + private function mockTranstype(NodeTypeInterface $nodeType): void { $sourceClass = $nodeType->getSourceEntityFullQualifiedClassName(); if (!class_exists($sourceClass)) { diff --git a/lib/RoadizCoreBundle/src/Node/UniversalDataDuplicator.php b/lib/RoadizCoreBundle/src/Node/UniversalDataDuplicator.php index c3c0a2ae7..faf8408f2 100644 --- a/lib/RoadizCoreBundle/src/Node/UniversalDataDuplicator.php +++ b/lib/RoadizCoreBundle/src/Node/UniversalDataDuplicator.php @@ -97,7 +97,7 @@ private function hasDefaultTranslation(NodesSources $source): bool return 1 === $sourceCount; } - protected function duplicateNonVirtualField( + private function duplicateNonVirtualField( NodesSources $universalSource, NodesSources $destSource, NodeTypeFieldInterface $field, @@ -108,7 +108,7 @@ protected function duplicateNonVirtualField( $destSource->$setter($universalSource->$getter()); } - protected function duplicateDocumentsField( + private function duplicateDocumentsField( NodesSources $universalSource, NodesSources $destSource, NodeTypeFieldInterface $field, diff --git a/lib/RoadizCoreBundle/src/NodeType/ApiResourceGenerator.php b/lib/RoadizCoreBundle/src/NodeType/ApiResourceGenerator.php index bbbc46667..66a22a63d 100644 --- a/lib/RoadizCoreBundle/src/NodeType/ApiResourceGenerator.php +++ b/lib/RoadizCoreBundle/src/NodeType/ApiResourceGenerator.php @@ -76,9 +76,9 @@ public function generate(NodeTypeInterface $nodeType): ?string \clearstatcache(true, $resourcePath); return $resourcePath; - } else { - return null; } + + return null; } public function remove(NodeTypeInterface $nodeType): void @@ -122,12 +122,12 @@ public function getResourcePath(NodeTypeInterface $nodeType): string ->toString(); } - protected function getWebResponseResourcePath(): string + private function getWebResponseResourcePath(): string { return $this->apiResourcesDir.'/web_response.yml'; } - protected function getResourceName(string $nodeTypeName): string + private function getResourceName(string $nodeTypeName): string { return (new UnicodeString($nodeTypeName)) ->snake() @@ -135,14 +135,14 @@ protected function getResourceName(string $nodeTypeName): string ->toString(); } - protected function getResourceUriPrefix(NodeTypeInterface $nodeType): string + private function getResourceUriPrefix(NodeTypeInterface $nodeType): string { $pluralNodeTypeName = InflectorFactory::create()->build()->pluralize($nodeType->getName()); return '/'.$this->getResourceName($pluralNodeTypeName); } - protected function getApiResourceDefinition(NodeTypeInterface $nodeType): array + private function getApiResourceDefinition(NodeTypeInterface $nodeType): array { $fqcn = (new UnicodeString($nodeType->getSourceEntityFullQualifiedClassName())) ->trimStart('\\') @@ -162,7 +162,7 @@ protected function getApiResourceDefinition(NodeTypeInterface $nodeType): array ]; } - protected function addWebResponseResourceOperation(NodeTypeInterface $nodeType, string $webResponseResourcePath): array + private function addWebResponseResourceOperation(NodeTypeInterface $nodeType, string $webResponseResourcePath): array { $getByPathOperationName = $this->apiResourceOperationNameGenerator->generateGetByPath( $nodeType->getSourceEntityFullQualifiedClassName() @@ -238,7 +238,7 @@ protected function addWebResponseResourceOperation(NodeTypeInterface $nodeType, return $webResponseResource; } - protected function removeWebResponseResourceOperation(NodeTypeInterface $nodeType, string $webResponseResourcePath): array + private function removeWebResponseResourceOperation(NodeTypeInterface $nodeType, string $webResponseResourcePath): array { $getByPathOperationName = $this->apiResourceOperationNameGenerator->generateGetByPath( $nodeType->getSourceEntityFullQualifiedClassName() @@ -264,7 +264,7 @@ protected function removeWebResponseResourceOperation(NodeTypeInterface $nodeTyp return $webResponseResource; } - protected function getCollectionOperations(NodeTypeInterface $nodeType): array + private function getCollectionOperations(NodeTypeInterface $nodeType): array { if (!$nodeType->isReachable()) { return []; @@ -331,7 +331,7 @@ protected function getCollectionOperations(NodeTypeInterface $nodeType): array return $operations; } - protected function getItemOperationSerializationGroups(NodeTypeInterface $nodeType): array + private function getItemOperationSerializationGroups(NodeTypeInterface $nodeType): array { return [ 'nodes_sources', @@ -346,7 +346,7 @@ protected function getItemOperationSerializationGroups(NodeTypeInterface $nodeTy ]; } - protected function getItemOperations(NodeTypeInterface $nodeType): array + private function getItemOperations(NodeTypeInterface $nodeType): array { if (!$nodeType->isReachable()) { return []; @@ -369,7 +369,7 @@ protected function getItemOperations(NodeTypeInterface $nodeType): array ]; } - protected function getGroupedFieldsSerializationGroups(NodeTypeInterface $nodeType): array + private function getGroupedFieldsSerializationGroups(NodeTypeInterface $nodeType): array { $groups = []; foreach ($nodeType->getFields() as $field) { diff --git a/lib/RoadizCoreBundle/src/NodeType/DefaultValuesResolver.php b/lib/RoadizCoreBundle/src/NodeType/DefaultValuesResolver.php index d13741203..30e44d69a 100644 --- a/lib/RoadizCoreBundle/src/NodeType/DefaultValuesResolver.php +++ b/lib/RoadizCoreBundle/src/NodeType/DefaultValuesResolver.php @@ -26,27 +26,26 @@ public function getDefaultValuesAmongAllFields(NodeTypeFieldInterface $field): a */ if (Configuration::INHERITANCE_TYPE_JOINED === $this->inheritanceType) { return array_map('trim', $field->getDefaultValuesAsArray()); - } else { - /* - * With single table inheritance, we need to get all default values - * from all fields of all node types. - */ - $defaultValues = []; - $nodeTypeFields = []; - $nodeTypes = $this->nodeTypesBag->all(); - foreach ($nodeTypes as $nodeType) { - $nodeTypeFields = [ - ...$nodeTypeFields, - ...$nodeType->getFields()->filter(fn (NodeTypeFieldInterface $nodeTypeField) => $nodeTypeField->getName() === $field->getName() && $nodeTypeField->getType() === $field->getType())->toArray(), - ]; - } - foreach ($nodeTypeFields as $nodeTypeField) { - $values = array_filter(array_map('trim', $nodeTypeField->getDefaultValuesAsArray())); - $defaultValues = array_merge($defaultValues, $values); - } - - return $defaultValues; } + /* + * With single table inheritance, we need to get all default values + * from all fields of all node types. + */ + $defaultValues = []; + $nodeTypeFields = []; + $nodeTypes = $this->nodeTypesBag->all(); + foreach ($nodeTypes as $nodeType) { + $nodeTypeFields = [ + ...$nodeTypeFields, + ...$nodeType->getFields()->filter(fn (NodeTypeFieldInterface $nodeTypeField) => $nodeTypeField->getName() === $field->getName() && $nodeTypeField->getType() === $field->getType())->toArray(), + ]; + } + foreach ($nodeTypeFields as $nodeTypeField) { + $values = array_filter(array_map('trim', $nodeTypeField->getDefaultValuesAsArray())); + $defaultValues = array_merge($defaultValues, $values); + } + + return $defaultValues; } #[\Override] diff --git a/lib/RoadizCoreBundle/src/NodeType/NodeTypeResolver.php b/lib/RoadizCoreBundle/src/NodeType/NodeTypeResolver.php index 328abf6c6..a79b2265a 100644 --- a/lib/RoadizCoreBundle/src/NodeType/NodeTypeResolver.php +++ b/lib/RoadizCoreBundle/src/NodeType/NodeTypeResolver.php @@ -18,7 +18,7 @@ public function __construct(private CacheItemPoolInterface $cacheAdapter) /** * @return array */ - protected function getNodeTypeList(NodeTypeFieldInterface $field): array + private function getNodeTypeList(NodeTypeFieldInterface $field): array { return array_filter($field->getDefaultValuesAsArray()); } diff --git a/lib/RoadizCoreBundle/src/Preview/EventSubscriber/PreviewBarSubscriber.php b/lib/RoadizCoreBundle/src/Preview/EventSubscriber/PreviewBarSubscriber.php index e575311d4..bcfc2df73 100644 --- a/lib/RoadizCoreBundle/src/Preview/EventSubscriber/PreviewBarSubscriber.php +++ b/lib/RoadizCoreBundle/src/Preview/EventSubscriber/PreviewBarSubscriber.php @@ -24,7 +24,7 @@ public static function getSubscribedEvents(): array ]; } - protected function supports(ResponseEvent $event): bool + private function supports(ResponseEvent $event): bool { $response = $event->getResponse(); if ( diff --git a/lib/RoadizCoreBundle/src/Preview/EventSubscriber/PreviewModeSubscriber.php b/lib/RoadizCoreBundle/src/Preview/EventSubscriber/PreviewModeSubscriber.php index 9a812d6f4..1cb8d6fbc 100644 --- a/lib/RoadizCoreBundle/src/Preview/EventSubscriber/PreviewModeSubscriber.php +++ b/lib/RoadizCoreBundle/src/Preview/EventSubscriber/PreviewModeSubscriber.php @@ -34,7 +34,7 @@ public static function getSubscribedEvents(): array ]; } - protected function supports(): bool + private function supports(): bool { return $this->previewResolver->isPreview(); } diff --git a/lib/RoadizCoreBundle/src/Repository/DocumentRepository.php b/lib/RoadizCoreBundle/src/Repository/DocumentRepository.php index 9504fcfce..05878e58a 100644 --- a/lib/RoadizCoreBundle/src/Repository/DocumentRepository.php +++ b/lib/RoadizCoreBundle/src/Repository/DocumentRepository.php @@ -428,9 +428,9 @@ public function findBy( * if a limit is set because of the default inner join */ return (new Paginator($query))->getIterator()->getArrayCopy(); - } else { - return $query->getResult(); } + + return $query->getResult(); } /** diff --git a/lib/RoadizCoreBundle/src/Repository/EntityRepository.php b/lib/RoadizCoreBundle/src/Repository/EntityRepository.php index 83c3b6de1..692bef1b1 100644 --- a/lib/RoadizCoreBundle/src/Repository/EntityRepository.php +++ b/lib/RoadizCoreBundle/src/Repository/EntityRepository.php @@ -330,9 +330,9 @@ public function searchBy( * if a limit is set because of the default inner join */ return (new Paginator($query))->getIterator()->getArrayCopy(); - } else { - return $query->getResult(); } + + return $query->getResult(); } /** diff --git a/lib/RoadizCoreBundle/src/Repository/NodeRepository.php b/lib/RoadizCoreBundle/src/Repository/NodeRepository.php index 79be63f66..d0f77b51e 100644 --- a/lib/RoadizCoreBundle/src/Repository/NodeRepository.php +++ b/lib/RoadizCoreBundle/src/Repository/NodeRepository.php @@ -296,9 +296,9 @@ public function findBy( * if a limit is set because of the default inner join */ return (new Paginator($query))->getIterator()->getArrayCopy(); - } else { - return $query->getResult(); } + + return $query->getResult(); } /** diff --git a/lib/RoadizCoreBundle/src/Repository/NodesSourcesRepository.php b/lib/RoadizCoreBundle/src/Repository/NodesSourcesRepository.php index 44e363d50..3a450243f 100644 --- a/lib/RoadizCoreBundle/src/Repository/NodesSourcesRepository.php +++ b/lib/RoadizCoreBundle/src/Repository/NodesSourcesRepository.php @@ -390,9 +390,9 @@ public function findBy( * if a limit is set because of the default inner join */ return (new Paginator($query))->getIterator()->getArrayCopy(); - } else { - return $query->getResult(); } + + return $query->getResult(); } /** diff --git a/lib/RoadizCoreBundle/src/Repository/PrefixAwareRepository.php b/lib/RoadizCoreBundle/src/Repository/PrefixAwareRepository.php index 70b7e36f4..3b13b7c0a 100644 --- a/lib/RoadizCoreBundle/src/Repository/PrefixAwareRepository.php +++ b/lib/RoadizCoreBundle/src/Repository/PrefixAwareRepository.php @@ -176,9 +176,9 @@ public function findBy( * if a limit is set because of the default inner join */ return (new Paginator($query))->getIterator()->getArrayCopy(); - } else { - return $query->getResult(); } + + return $query->getResult(); } /** @@ -264,9 +264,9 @@ public function searchBy( * if a limit is set because of the default inner join */ return (new Paginator($query))->getIterator()->getArrayCopy(); - } else { - return $query->getResult(); } + + return $query->getResult(); } #[\Override] diff --git a/lib/RoadizCoreBundle/src/Repository/TagRepository.php b/lib/RoadizCoreBundle/src/Repository/TagRepository.php index c834f0536..e43980238 100644 --- a/lib/RoadizCoreBundle/src/Repository/TagRepository.php +++ b/lib/RoadizCoreBundle/src/Repository/TagRepository.php @@ -242,9 +242,9 @@ public function findBy( * if a limit is set because of the default inner join */ return (new Paginator($query))->getIterator()->getArrayCopy(); - } else { - return $query->getResult(); } + + return $query->getResult(); } /** diff --git a/lib/RoadizCoreBundle/src/Routing/NodeRouteHelper.php b/lib/RoadizCoreBundle/src/Routing/NodeRouteHelper.php index 4a6084d77..2bc1f9556 100644 --- a/lib/RoadizCoreBundle/src/Routing/NodeRouteHelper.php +++ b/lib/RoadizCoreBundle/src/Routing/NodeRouteHelper.php @@ -69,7 +69,7 @@ public function getController(): ?string return $this->controller; } - protected function getControllerNamespace(): string + private function getControllerNamespace(): string { return $this->defaultControllerNamespace; } diff --git a/lib/RoadizCoreBundle/src/Routing/NodesSourcesUrlGenerator.php b/lib/RoadizCoreBundle/src/Routing/NodesSourcesUrlGenerator.php index d847c7047..91f8e383e 100644 --- a/lib/RoadizCoreBundle/src/Routing/NodesSourcesUrlGenerator.php +++ b/lib/RoadizCoreBundle/src/Routing/NodesSourcesUrlGenerator.php @@ -19,7 +19,7 @@ public function __construct( ) { } - protected function isNodeSourceHome(NodesSources $nodeSource): bool + private function isNodeSourceHome(NodesSources $nodeSource): bool { if ($nodeSource->getNode()->isHome()) { return true; @@ -46,9 +46,9 @@ public function getNonContextualUrl(array $parameters = []): string && false === $this->forceLocale ) { return ''; - } else { - return $this->nodeSource->getTranslation()->getPreferredLocale(); } + + return $this->nodeSource->getTranslation()->getPreferredLocale(); } $path = $this->pathAggregator->aggregatePath($this->nodeSource, $parameters); @@ -71,7 +71,7 @@ public function getNonContextualUrl(array $parameters = []): string return $path; } - protected function useUrlAlias(NodesSources $nodesSources): bool + private function useUrlAlias(NodesSources $nodesSources): bool { if ($nodesSources->getIdentifier() !== $nodesSources->getNode()->getNodeName()) { return true; @@ -80,7 +80,7 @@ protected function useUrlAlias(NodesSources $nodesSources): bool return false; } - protected function urlNeedsLocalePrefix(NodesSources $nodesSources): bool + private function urlNeedsLocalePrefix(NodesSources $nodesSources): bool { /* * Needs a prefix only if translation is not default AND nodeSource does not have an Url alias diff --git a/lib/RoadizCoreBundle/src/Routing/ResourceInfo.php b/lib/RoadizCoreBundle/src/Routing/ResourceInfo.php index 47b128d7f..7e06ab88c 100644 --- a/lib/RoadizCoreBundle/src/Routing/ResourceInfo.php +++ b/lib/RoadizCoreBundle/src/Routing/ResourceInfo.php @@ -9,10 +9,10 @@ final class ResourceInfo { - protected ?PersistableInterface $resource = null; - protected ?TranslationInterface $translation = null; - protected ?string $format = null; - protected ?string $locale = null; + private ?PersistableInterface $resource = null; + private ?TranslationInterface $translation = null; + private ?string $format = null; + private ?string $locale = null; public function getResource(): ?PersistableInterface { diff --git a/lib/RoadizCoreBundle/src/SearchEngine/GlobalNodeSourceSearchHandler.php b/lib/RoadizCoreBundle/src/SearchEngine/GlobalNodeSourceSearchHandler.php index d6d2cc401..c80753435 100644 --- a/lib/RoadizCoreBundle/src/SearchEngine/GlobalNodeSourceSearchHandler.php +++ b/lib/RoadizCoreBundle/src/SearchEngine/GlobalNodeSourceSearchHandler.php @@ -19,7 +19,7 @@ public function __construct( ) { } - protected function getRepository(): NodesSourcesRepository + private function getRepository(): NodesSourcesRepository { return $this->allStatusesNodesSourcesRepository; } diff --git a/lib/RoadizCoreBundle/src/Security/Authorization/AccessDeniedHandler.php b/lib/RoadizCoreBundle/src/Security/Authorization/AccessDeniedHandler.php index f1935cf3d..4f628df31 100644 --- a/lib/RoadizCoreBundle/src/Security/Authorization/AccessDeniedHandler.php +++ b/lib/RoadizCoreBundle/src/Security/Authorization/AccessDeniedHandler.php @@ -54,15 +54,14 @@ public function handle(Request $request, AccessDeniedException $accessDeniedExce ], Response::HTTP_FORBIDDEN ); + } + if ('' !== $this->redirectRoute) { + $redirectUrl = $this->urlGenerator->generate($this->redirectRoute, $this->redirectParameters); } else { - if ('' !== $this->redirectRoute) { - $redirectUrl = $this->urlGenerator->generate($this->redirectRoute, $this->redirectParameters); - } else { - $redirectUrl = $request->getBaseUrl(); - } - - // Forbidden code should be set on final response, not the redirection! - return new RedirectResponse($redirectUrl, Response::HTTP_FOUND); + $redirectUrl = $request->getBaseUrl(); } + + // Forbidden code should be set on final response, not the redirection! + return new RedirectResponse($redirectUrl, Response::HTTP_FOUND); } } diff --git a/lib/RoadizCoreBundle/src/Security/Authorization/Chroot/NodeChrootChainResolver.php b/lib/RoadizCoreBundle/src/Security/Authorization/Chroot/NodeChrootChainResolver.php index 217ddca14..d73f311f3 100644 --- a/lib/RoadizCoreBundle/src/Security/Authorization/Chroot/NodeChrootChainResolver.php +++ b/lib/RoadizCoreBundle/src/Security/Authorization/Chroot/NodeChrootChainResolver.php @@ -17,7 +17,7 @@ public function __construct(private array $resolvers) { foreach ($this->resolvers as $resolver) { - if (!($resolver instanceof NodeChrootResolver)) { + if (!$resolver instanceof NodeChrootResolver) { throw new \InvalidArgumentException('Resolver must implements '.NodeChrootResolver::class); } } diff --git a/lib/RoadizCoreBundle/src/Security/Authorization/Voter/GroupVoter.php b/lib/RoadizCoreBundle/src/Security/Authorization/Voter/GroupVoter.php index 6bc3c63bb..833b2c8ef 100644 --- a/lib/RoadizCoreBundle/src/Security/Authorization/Voter/GroupVoter.php +++ b/lib/RoadizCoreBundle/src/Security/Authorization/Voter/GroupVoter.php @@ -38,7 +38,7 @@ public function vote(TokenInterface $token, $subject, array $attributes, ?Vote $ $user = $token->getUser(); foreach ($attributes as $attribute) { - if (!($attribute instanceof Group)) { + if (!$attribute instanceof Group) { return VoterInterface::ACCESS_ABSTAIN; } diff --git a/lib/RoadizCoreBundle/src/Security/Authorization/Voter/NodeVoter.php b/lib/RoadizCoreBundle/src/Security/Authorization/Voter/NodeVoter.php index 705cc8e9f..7cf4b736a 100644 --- a/lib/RoadizCoreBundle/src/Security/Authorization/Voter/NodeVoter.php +++ b/lib/RoadizCoreBundle/src/Security/Authorization/Voter/NodeVoter.php @@ -121,11 +121,10 @@ private function isNodeInsideUserChroot(NodeInterface $node, NodeInterface $chro $vote?->addReason('Chroot itself is not allowed for this attribute, access denied.'); return false; - } else { - $vote?->addReason('Chroot itself is allowed for this attribute, access granted.'); - - return true; } + $vote?->addReason('Chroot itself is allowed for this attribute, access granted.'); + + return true; } /* diff --git a/lib/RoadizCoreBundle/src/Security/LogTrail.php b/lib/RoadizCoreBundle/src/Security/LogTrail.php index 22069b273..27a90f98f 100644 --- a/lib/RoadizCoreBundle/src/Security/LogTrail.php +++ b/lib/RoadizCoreBundle/src/Security/LogTrail.php @@ -37,7 +37,7 @@ public function publishErrorMessage(?Request $request, string $msg, ?object $sou * Publish a message in Session flash bag and * logger interface. */ - protected function publishMessage( + private function publishMessage( ?Request $request, string $msg, string $level = 'confirm', diff --git a/lib/RoadizCoreBundle/src/Security/User/UserProvider.php b/lib/RoadizCoreBundle/src/Security/User/UserProvider.php index 9d57e1384..3261e9394 100644 --- a/lib/RoadizCoreBundle/src/Security/User/UserProvider.php +++ b/lib/RoadizCoreBundle/src/Security/User/UserProvider.php @@ -25,7 +25,7 @@ public function loadUserByUsername(string $username): UserInterface return $this->loadUserByUsernameOrEmail($username); } - protected function loadUserByUsernameOrEmail(string $identifier): UserInterface + private function loadUserByUsernameOrEmail(string $identifier): UserInterface { /** @var User|null $user */ $user = $this->managerRegistry @@ -41,9 +41,8 @@ protected function loadUserByUsernameOrEmail(string $identifier): UserInterface if (null !== $user) { return $user; - } else { - throw new UserNotFoundException(); } + throw new UserNotFoundException(); } #[\Override] @@ -79,9 +78,8 @@ public function refreshUser(UserInterface $user): UserInterface ) { // Always refresh User from database: too much related entities to rely only on token. return $refreshUser; - } else { - throw new UserNotFoundException('Token user does not exist anymore, authenticate again…'); } + throw new UserNotFoundException('Token user does not exist anymore, authenticate again…'); } throw new UnsupportedUserException(); } diff --git a/lib/RoadizCoreBundle/src/Serializer/Normalizer/RealmSerializationGroupNormalizer.php b/lib/RoadizCoreBundle/src/Serializer/Normalizer/RealmSerializationGroupNormalizer.php index ae2fe6efc..8c4d2f1be 100644 --- a/lib/RoadizCoreBundle/src/Serializer/Normalizer/RealmSerializationGroupNormalizer.php +++ b/lib/RoadizCoreBundle/src/Serializer/Normalizer/RealmSerializationGroupNormalizer.php @@ -30,7 +30,7 @@ public function __construct( #[\Override] public function supportsNormalization(mixed $data, ?string $format = null, array $context = []): bool { - if (!($data instanceof NodesSources)) { + if (!$data instanceof NodesSources) { return false; } // Make sure we're not called twice diff --git a/lib/RoadizCoreBundle/src/Serializer/Normalizer/TranslationAwareNormalizer.php b/lib/RoadizCoreBundle/src/Serializer/Normalizer/TranslationAwareNormalizer.php index 3f031a523..8d3b6ce7f 100644 --- a/lib/RoadizCoreBundle/src/Serializer/Normalizer/TranslationAwareNormalizer.php +++ b/lib/RoadizCoreBundle/src/Serializer/Normalizer/TranslationAwareNormalizer.php @@ -61,9 +61,9 @@ private function getTranslationFromLocale(string $locale): ?TranslationInterface if ($this->previewResolver->isPreview()) { return $repository->findOneByLocaleOrOverrideLocale($locale); - } else { - return $repository->findOneAvailableByLocaleOrOverrideLocale($locale); } + + return $repository->findOneAvailableByLocaleOrOverrideLocale($locale); } private function getTranslationFromRequest(): ?TranslationInterface diff --git a/lib/RoadizCoreBundle/src/TwigExtension/BlockRenderExtension.php b/lib/RoadizCoreBundle/src/TwigExtension/BlockRenderExtension.php index e3d14bb56..4f36de6fa 100644 --- a/lib/RoadizCoreBundle/src/TwigExtension/BlockRenderExtension.php +++ b/lib/RoadizCoreBundle/src/TwigExtension/BlockRenderExtension.php @@ -50,9 +50,8 @@ public function blockRender(?NodesSources $nodeSource = null, string $themeName return $this->handler->render($controllerReference, 'inline', [ 'ignore_errors' => false, ]); - } else { - throw new RuntimeError($class.'::blockAction() action does not exist.'); } + throw new RuntimeError($class.'::blockAction() action does not exist.'); } else { throw new RuntimeError('Invalid name formatting for your theme.'); } diff --git a/lib/RoadizCoreBundle/src/TwigExtension/DocumentUrlExtension.php b/lib/RoadizCoreBundle/src/TwigExtension/DocumentUrlExtension.php index 837fed15e..8047ccf6f 100644 --- a/lib/RoadizCoreBundle/src/TwigExtension/DocumentUrlExtension.php +++ b/lib/RoadizCoreBundle/src/TwigExtension/DocumentUrlExtension.php @@ -45,9 +45,9 @@ public function getUrl(?PersistableInterface $mixed = null, array $criteria = [] if (null === $mixed) { if ($this->throwExceptions) { throw new RuntimeError('Twig “url” filter must be used with a not null object'); - } else { - return ''; } + + return ''; } if ($mixed instanceof DocumentInterface) { diff --git a/lib/RoadizCoreBundle/src/TwigExtension/NodesSourcesExtension.php b/lib/RoadizCoreBundle/src/TwigExtension/NodesSourcesExtension.php index d1c9390b8..af8373d0a 100644 --- a/lib/RoadizCoreBundle/src/TwigExtension/NodesSourcesExtension.php +++ b/lib/RoadizCoreBundle/src/TwigExtension/NodesSourcesExtension.php @@ -70,9 +70,9 @@ public function getChildren(?NodesSources $ns = null, ?array $criteria = null, ? if (null === $ns) { if ($this->throwExceptions) { throw new RuntimeError('Cannot get children from a NULL node-source.'); - } else { - return []; } + + return []; } if ($displayNotPublished) { @@ -92,9 +92,9 @@ public function getNext(?NodesSources $ns = null, ?array $criteria = null, ?arra if (null === $ns) { if ($this->throwExceptions) { throw new RuntimeError('Cannot get next sibling from a NULL node-source.'); - } else { - return null; } + + return null; } if ($displayNotPublished) { @@ -114,9 +114,9 @@ public function getPrevious(?NodesSources $ns = null, ?array $criteria = null, ? if (null === $ns) { if ($this->throwExceptions) { throw new RuntimeError('Cannot get previous sibling from a NULL node-source.'); - } else { - return null; } + + return null; } if ($displayNotPublished) { @@ -136,9 +136,9 @@ public function getLastSibling(?NodesSources $ns = null, ?array $criteria = null if (null === $ns) { if ($this->throwExceptions) { throw new RuntimeError('Cannot get last sibling from a NULL node-source.'); - } else { - return null; } + + return null; } if ($displayNotPublished) { @@ -158,9 +158,9 @@ public function getFirstSibling(?NodesSources $ns = null, ?array $criteria = nul if (null === $ns) { if ($this->throwExceptions) { throw new RuntimeError('Cannot get first sibling from a NULL node-source.'); - } else { - return null; } + + return null; } if ($displayNotPublished) { @@ -180,9 +180,9 @@ public function getParent(?NodesSources $ns = null): ?NodesSources if (null === $ns) { if ($this->throwExceptions) { throw new RuntimeError('Cannot get parent from a NULL node-source.'); - } else { - return null; } + + return null; } return $ns->getParent(); @@ -199,9 +199,9 @@ public function getParents(?NodesSources $ns = null, ?array $criteria = null, bo if (null === $ns) { if ($this->throwExceptions) { throw new RuntimeError('Cannot get parents from a NULL node-source.'); - } else { - return []; } + + return []; } if ($displayNotPublished) { @@ -225,9 +225,9 @@ public function getTags(?NodesSources $ns = null): iterable if (null === $ns) { if ($this->throwExceptions) { throw new RuntimeError('Cannot get tags from a NULL node-source.'); - } else { - return []; } + + return []; } return $this->tagRepository->findByNodesSources($ns); diff --git a/lib/RoadizFontBundle/src/Entity/Font.php b/lib/RoadizFontBundle/src/Entity/Font.php index 1ebbd264f..690609bec 100644 --- a/lib/RoadizFontBundle/src/Entity/Font.php +++ b/lib/RoadizFontBundle/src/Entity/Font.php @@ -19,15 +19,13 @@ * Fonts are entities which store each webfont file for a * font-family and a font-variant. */ -#[ - ORM\Entity(repositoryClass: FontRepository::class), +#[ORM\Entity(repositoryClass: FontRepository::class), ORM\Table(name: 'fonts'), ORM\HasLifecycleCallbacks, ORM\UniqueConstraint(columns: ['name', 'variant']), ORM\Index(columns: ['created_at'], name: 'font_created_at'), ORM\Index(columns: ['updated_at'], name: 'font_updated_at'), - UniqueEntity(fields: ['name', 'variant']) -] + UniqueEntity(fields: ['name', 'variant'])] class Font implements DateTimedInterface, PersistableInterface { use SequentialIdTrait; diff --git a/lib/RoadizRozierBundle/src/Controller/AbstractAdminController.php b/lib/RoadizRozierBundle/src/Controller/AbstractAdminController.php index e9d8f8084..beab80490 100644 --- a/lib/RoadizRozierBundle/src/Controller/AbstractAdminController.php +++ b/lib/RoadizRozierBundle/src/Controller/AbstractAdminController.php @@ -159,7 +159,7 @@ public function editAction(Request $request, int|string $id): ?Response { /** @var mixed|object|null $item */ $item = $this->getRepository()->find($id); - if (!($item instanceof PersistableInterface)) { + if (!$item instanceof PersistableInterface) { throw $this->createNotFoundException(); } @@ -214,7 +214,7 @@ public function deleteAction(Request $request, int|string $id): ?Response /** @var mixed|object|null $item */ $item = $this->getRepository()->find($id); - if (!($item instanceof PersistableInterface)) { + if (!$item instanceof PersistableInterface) { throw $this->createNotFoundException(); } diff --git a/lib/RoadizRozierBundle/src/Controller/Document/DocumentController.php b/lib/RoadizRozierBundle/src/Controller/Document/DocumentController.php index 29d2db3a7..ee573005e 100644 --- a/lib/RoadizRozierBundle/src/Controller/Document/DocumentController.php +++ b/lib/RoadizRozierBundle/src/Controller/Document/DocumentController.php @@ -230,19 +230,18 @@ public function uploadAction(Request $request, ?int $folderId = null, string $_f 'success' => true, 'document' => $documentModel->toArray(), ], Response::HTTP_CREATED); - } else { - return $this->redirectToRoute('documentsHomePage', ['folderId' => $folderId]); } - } else { - $msg = $this->translator->trans('document.cannot_persist'); - $this->logTrail->publishErrorMessage($request, $msg, $document); - if ('json' === $_format || $request->isXmlHttpRequest()) { - throw $this->createNotFoundException($msg); - } else { - return $this->redirectToRoute('documentsHomePage', ['folderId' => $folderId]); - } + return $this->redirectToRoute('documentsHomePage', ['folderId' => $folderId]); + } + $msg = $this->translator->trans('document.cannot_persist'); + $this->logTrail->publishErrorMessage($request, $msg, $document); + + if ('json' === $_format || $request->isXmlHttpRequest()) { + throw $this->createNotFoundException($msg); } + + return $this->redirectToRoute('documentsHomePage', ['folderId' => $folderId]); } elseif ('json' === $_format || $request->isXmlHttpRequest()) { /* * Bad form submitted diff --git a/lib/RoadizRozierBundle/src/Controller/Document/DocumentEmbedController.php b/lib/RoadizRozierBundle/src/Controller/Document/DocumentEmbedController.php index 8a6973ac6..316d548c0 100644 --- a/lib/RoadizRozierBundle/src/Controller/Document/DocumentEmbedController.php +++ b/lib/RoadizRozierBundle/src/Controller/Document/DocumentEmbedController.php @@ -189,9 +189,8 @@ private function embedDocument(array $data, ?int $folderId = null): DocumentInte } return $this->createDocumentFromFinder($finder, $folderId); - } else { - throw new \RuntimeException('bad.request', 1); } + throw new \RuntimeException('bad.request', 1); } /** diff --git a/lib/RoadizRozierBundle/src/Controller/GroupController.php b/lib/RoadizRozierBundle/src/Controller/GroupController.php index 533959541..587e75b1c 100644 --- a/lib/RoadizRozierBundle/src/Controller/GroupController.php +++ b/lib/RoadizRozierBundle/src/Controller/GroupController.php @@ -149,7 +149,7 @@ public function removeRolesAction(Request $request, int $id, string $role): Resp /** @var Group|null $item */ $item = $this->em()->find($this->getEntityClass(), $id); - if (!($item instanceof Group)) { + if (!$item instanceof Group) { throw $this->createNotFoundException(); } @@ -195,7 +195,7 @@ public function editUsersAction(Request $request, int $id): Response /** @var Group|null $item */ $item = $this->em()->find($this->getEntityClass(), $id); - if (!($item instanceof Group)) { + if (!$item instanceof Group) { throw $this->createNotFoundException(); } @@ -243,7 +243,7 @@ public function removeUsersAction(Request $request, int $id, int $userId): Respo /** @var User|null $user */ $user = $this->em()->find(User::class, $userId); - if (!($item instanceof Group)) { + if (!$item instanceof Group) { throw $this->createNotFoundException(); } diff --git a/lib/RoadizRozierBundle/src/Controller/Node/NodeAttributeController.php b/lib/RoadizRozierBundle/src/Controller/Node/NodeAttributeController.php index fd94d2f2b..8ca4a4fb9 100644 --- a/lib/RoadizRozierBundle/src/Controller/Node/NodeAttributeController.php +++ b/lib/RoadizRozierBundle/src/Controller/Node/NodeAttributeController.php @@ -151,21 +151,20 @@ public function editAction(Request $request, int $nodeId, int $translationId): R 'nodeId' => $node->getId(), 'translationId' => $translation->getId(), ]); - } else { - $errors = $this->formErrorSerializer->getErrorsAsArray($attributeValueTranslationForm); - /* - * Handle errors when Ajax POST requests - */ - if ($isJson) { - return new JsonResponse([ - 'status' => 'fail', - 'errors' => $errors, - 'message' => $this->translator->trans('form_has_errors.check_you_fields'), - ], Response::HTTP_UNPROCESSABLE_ENTITY); - } - foreach ($errors as $error) { - $this->logTrail->publishErrorMessage($request, $error); - } + } + $errors = $this->formErrorSerializer->getErrorsAsArray($attributeValueTranslationForm); + /* + * Handle errors when Ajax POST requests + */ + if ($isJson) { + return new JsonResponse([ + 'status' => 'fail', + 'errors' => $errors, + 'message' => $this->translator->trans('form_has_errors.check_you_fields'), + ], Response::HTTP_UNPROCESSABLE_ENTITY); + } + foreach ($errors as $error) { + $this->logTrail->publishErrorMessage($request, $error); } } diff --git a/lib/RoadizRozierBundle/src/Controller/Node/NodeBulkActionTrait.php b/lib/RoadizRozierBundle/src/Controller/Node/NodeBulkActionTrait.php index 54d3f96a7..7170d5154 100644 --- a/lib/RoadizRozierBundle/src/Controller/Node/NodeBulkActionTrait.php +++ b/lib/RoadizRozierBundle/src/Controller/Node/NodeBulkActionTrait.php @@ -92,9 +92,9 @@ public function bulkDeleteAction(Request $request): Response if (!empty($form->getData()['referer'])) { return $this->redirect($form->getData()['referer']); - } else { - return $this->redirectToRoute('nodesHomePage'); } + + return $this->redirectToRoute('nodesHomePage'); } $assignation['nodes'] = $nodes; @@ -149,9 +149,9 @@ public function bulkStatusAction(Request $request): Response if (!empty($form->getData()['referer'])) { return $this->redirect($form->getData()['referer']); - } else { - return $this->redirectToRoute('nodesHomePage'); } + + return $this->redirectToRoute('nodesHomePage'); } $assignation['nodes'] = $nodes; diff --git a/lib/RoadizRozierBundle/src/Controller/Node/SeoController.php b/lib/RoadizRozierBundle/src/Controller/Node/SeoController.php index ab4aba9a5..2e56c4be7 100644 --- a/lib/RoadizRozierBundle/src/Controller/Node/SeoController.php +++ b/lib/RoadizRozierBundle/src/Controller/Node/SeoController.php @@ -187,12 +187,11 @@ private function addNodeUrlAlias(UrlAlias $alias, Node $node, Translation $trans $entityManager->flush(); return $alias; - } else { - $msg = $this->translator->trans('url_alias.no_translation.%translation%', [ - '%translation%' => $translation->getName(), - ]); - throw new NoTranslationAvailableException($msg); } + $msg = $this->translator->trans('url_alias.no_translation.%translation%', [ + '%translation%' => $translation->getName(), + ]); + throw new NoTranslationAvailableException($msg); } private function handleSingleUrlAlias( diff --git a/lib/RoadizRozierBundle/src/Controller/RedirectionController.php b/lib/RoadizRozierBundle/src/Controller/RedirectionController.php index 6390e1ea6..eb9b1c897 100644 --- a/lib/RoadizRozierBundle/src/Controller/RedirectionController.php +++ b/lib/RoadizRozierBundle/src/Controller/RedirectionController.php @@ -87,7 +87,7 @@ protected function getDefaultOrder(Request $request): array #[\Override] protected function createPostCreateEvent(PersistableInterface $item): RedirectionEvent { - if (!($item instanceof Redirection)) { + if (!$item instanceof Redirection) { throw new \InvalidArgumentException('Item should be instance of '.Redirection::class); } @@ -97,7 +97,7 @@ protected function createPostCreateEvent(PersistableInterface $item): Redirectio #[\Override] protected function createPostUpdateEvent(PersistableInterface $item): RedirectionEvent { - if (!($item instanceof Redirection)) { + if (!$item instanceof Redirection) { throw new \InvalidArgumentException('Item should be instance of '.Redirection::class); } @@ -107,7 +107,7 @@ protected function createPostUpdateEvent(PersistableInterface $item): Redirectio #[\Override] protected function createDeleteEvent(PersistableInterface $item): RedirectionEvent { - if (!($item instanceof Redirection)) { + if (!$item instanceof Redirection) { throw new \InvalidArgumentException('Item should be instance of '.Redirection::class); } diff --git a/lib/RoadizRozierBundle/src/Controller/SearchController.php b/lib/RoadizRozierBundle/src/Controller/SearchController.php index feed7c66e..f28dd2a05 100644 --- a/lib/RoadizRozierBundle/src/Controller/SearchController.php +++ b/lib/RoadizRozierBundle/src/Controller/SearchController.php @@ -373,14 +373,14 @@ protected function handleNodeTypeForm(FormInterface $nodeTypeForm): ?RedirectRes if ($nodeTypeForm->isSubmitted() && $nodeTypeForm->isValid()) { if (empty($nodeTypeForm->getData()['nodetype'])) { return $this->redirectToRoute('searchNodePage'); - } else { - return $this->redirectToRoute( - 'searchNodeSourcePage', - [ - 'nodeTypeName' => $nodeTypeForm->getData()['nodetype'], - ] - ); } + + return $this->redirectToRoute( + 'searchNodeSourcePage', + [ + 'nodeTypeName' => $nodeTypeForm->getData()['nodetype'], + ] + ); } return null; diff --git a/lib/RoadizRozierBundle/src/Controller/SecurityController.php b/lib/RoadizRozierBundle/src/Controller/SecurityController.php index c5253788e..2c31bff4d 100644 --- a/lib/RoadizRozierBundle/src/Controller/SecurityController.php +++ b/lib/RoadizRozierBundle/src/Controller/SecurityController.php @@ -72,7 +72,7 @@ public function requestLoginLink( $email = $request->getPayload()->get('email'); $user = $userRepository->findOneBy(['email' => $email]); - if (!($user instanceof UserInterface)) { + if (!$user instanceof UserInterface) { // Do not reveal whether a user account exists or not return $this->redirectToRoute('roadiz_rozier_login_link_sent'); } diff --git a/lib/RoadizRozierBundle/src/Controller/SettingController.php b/lib/RoadizRozierBundle/src/Controller/SettingController.php index d857754fa..5f1cb6a3e 100644 --- a/lib/RoadizRozierBundle/src/Controller/SettingController.php +++ b/lib/RoadizRozierBundle/src/Controller/SettingController.php @@ -159,11 +159,11 @@ private function handleSingleSettingForm( 'settingGroupsSettingsPage', ['settingGroupId' => $settingGroup->getId()] ); - } else { - return $this->redirectToRoute( - 'settingsHomePage' - ); } + + return $this->redirectToRoute( + 'settingsHomePage' + ); } catch (\RuntimeException $e) { $form->addError(new FormError($e->getMessage())); } diff --git a/lib/RoadizRozierBundle/src/Controller/Tag/TagController.php b/lib/RoadizRozierBundle/src/Controller/Tag/TagController.php index 64f7c865e..a95178e08 100644 --- a/lib/RoadizRozierBundle/src/Controller/Tag/TagController.php +++ b/lib/RoadizRozierBundle/src/Controller/Tag/TagController.php @@ -278,9 +278,9 @@ public function bulkDeleteAction(Request $request): Response if (!empty($form->getData()['referer'])) { return $this->redirect($form->getData()['referer']); - } else { - return $this->redirectToRoute('tagsHomePage'); } + + return $this->redirectToRoute('tagsHomePage'); } $assignation = []; diff --git a/lib/RoadizRozierBundle/src/Controller/User/UserController.php b/lib/RoadizRozierBundle/src/Controller/User/UserController.php index 9bae30283..4b8610cf0 100644 --- a/lib/RoadizRozierBundle/src/Controller/User/UserController.php +++ b/lib/RoadizRozierBundle/src/Controller/User/UserController.php @@ -159,7 +159,7 @@ public function editDetailsAction(Request $request, int $id): Response /** @var mixed|object|null $item */ $item = $this->em()->find($this->getEntityClass(), $id); - if (!($item instanceof PersistableInterface)) { + if (!$item instanceof PersistableInterface) { throw $this->createNotFoundException(); } diff --git a/lib/RoadizRozierBundle/src/Controller/WebhookController.php b/lib/RoadizRozierBundle/src/Controller/WebhookController.php index 659e47f08..15b082396 100644 --- a/lib/RoadizRozierBundle/src/Controller/WebhookController.php +++ b/lib/RoadizRozierBundle/src/Controller/WebhookController.php @@ -43,7 +43,7 @@ public function triggerAction(Request $request, string $id): Response /** @var Webhook|null $item */ $item = $this->em()->find($this->getEntityClass(), $id); - if (!($item instanceof PersistableInterface)) { + if (!$item instanceof PersistableInterface) { throw $this->createNotFoundException(); } diff --git a/lib/RoadizRozierBundle/src/DependencyInjection/Configuration.php b/lib/RoadizRozierBundle/src/DependencyInjection/Configuration.php index bfa3554aa..46820854f 100644 --- a/lib/RoadizRozierBundle/src/DependencyInjection/Configuration.php +++ b/lib/RoadizRozierBundle/src/DependencyInjection/Configuration.php @@ -72,7 +72,7 @@ public function getConfigTreeBuilder(): TreeBuilder return $builder; } - protected function addOpenIdNode(): NodeDefinition + private function addOpenIdNode(): NodeDefinition { $builder = new TreeBuilder('open_id'); $node = $builder->getRootNode(); @@ -157,7 +157,7 @@ protected function addOpenIdNode(): NodeDefinition return $node; } - protected function addCsvNode(): NodeDefinition + private function addCsvNode(): NodeDefinition { $builder = new TreeBuilder('csv_encoder_options'); $node = $builder->getRootNode(); diff --git a/lib/RoadizRozierBundle/src/Explorer/DocumentExplorerItem.php b/lib/RoadizRozierBundle/src/Explorer/DocumentExplorerItem.php index fd8163d33..ecf523796 100644 --- a/lib/RoadizRozierBundle/src/Explorer/DocumentExplorerItem.php +++ b/lib/RoadizRozierBundle/src/Explorer/DocumentExplorerItem.php @@ -81,7 +81,7 @@ public function getOriginal(): DocumentInterface #[\Override] protected function getEditItemPath(): ?string { - if (!($this->document instanceof PersistableInterface)) { + if (!$this->document instanceof PersistableInterface) { return null; } diff --git a/lib/RoadizRozierBundle/src/Explorer/NodeExplorerItem.php b/lib/RoadizRozierBundle/src/Explorer/NodeExplorerItem.php index 26ffacbbc..e9491c956 100644 --- a/lib/RoadizRozierBundle/src/Explorer/NodeExplorerItem.php +++ b/lib/RoadizRozierBundle/src/Explorer/NodeExplorerItem.php @@ -54,7 +54,7 @@ public function getAlternativeDisplayable(): ?string { $parent = $this->node->getParent(); - if (!($parent instanceof Node)) { + if (!$parent instanceof Node) { return null; } diff --git a/lib/RoadizRozierBundle/src/Explorer/NodeSourceExplorerItem.php b/lib/RoadizRozierBundle/src/Explorer/NodeSourceExplorerItem.php index 8b05f3e74..556f9cd10 100644 --- a/lib/RoadizRozierBundle/src/Explorer/NodeSourceExplorerItem.php +++ b/lib/RoadizRozierBundle/src/Explorer/NodeSourceExplorerItem.php @@ -33,7 +33,7 @@ public function getAlternativeDisplayable(): ?string { $parent = $this->nodeSource->getParent(); - if (!($parent instanceof NodesSources)) { + if (!$parent instanceof NodesSources) { return null; } diff --git a/lib/RoadizRozierBundle/src/Form/NodeTypeDecoratorType.php b/lib/RoadizRozierBundle/src/Form/NodeTypeDecoratorType.php index 4dec71839..174f166ce 100644 --- a/lib/RoadizRozierBundle/src/Form/NodeTypeDecoratorType.php +++ b/lib/RoadizRozierBundle/src/Form/NodeTypeDecoratorType.php @@ -75,9 +75,9 @@ private function getValueType(NodeTypeDecorator $nodeTypeDecorator): string return CheckboxType::class; } elseif (NodeTypeDecoratorProperty::NODE_TYPE_COLOR === $property) { return ColorType::class; - } else { - return TextType::class; } + + return TextType::class; } private function getValueOption(NodeTypeDecorator $nodeTypeDecorator): array @@ -89,12 +89,12 @@ private function getValueOption(NodeTypeDecorator $nodeTypeDecorator): array 'required' => false, 'html5' => true, ]; - } else { - return [ - 'label' => 'nodeTypeDecorator.value', - 'required' => false, - ]; } + + return [ + 'label' => 'nodeTypeDecorator.value', + 'required' => false, + ]; } private function getExplodedPath(string $path): array diff --git a/lib/RoadizSolrBundle/README.md b/lib/RoadizSolrBundle/README.md index 99f58f86a..a334d2251 100644 --- a/lib/RoadizSolrBundle/README.md +++ b/lib/RoadizSolrBundle/README.md @@ -115,10 +115,22 @@ nelmio_solarium: adapter_timeout: 5 ``` +Configure fuzzy search options in a dedicated `roadiz_solr` config file: +```yaml +# config/packages/roadiz_solr.yaml +roadiz_solr: + search: + fuzzy_proximity: 2 + fuzzy_min_term_length: 3 +``` + You can use Solr Cloud with a collection instead of a core by setting the `SOLR_COLLECTION_NAME` environment variable and commenting the `core` line. Then you will need to set the `SOLR_COLLECTION_NUM_SHARDS` and `SOLR_COLLECTION_REPLICATION_FACTOR` variables to configure your collection and execute `solr:init` command to create the collection. +Fuzzy search options should now be configured in `roadiz_solr.search`. +For backward compatibility, `roadiz_core.solr.search` is still read as a fallback during migration. + #### Extending Solr configuration If you want to add/remove fields and update filters you can add an event-subscriber to the `RZ\Roadiz\SolrBundle\Event\SolrInitializationEvent` event. diff --git a/lib/RoadizSolrBundle/config/packages/roadiz_solr.yaml b/lib/RoadizSolrBundle/config/packages/roadiz_solr.yaml new file mode 100644 index 000000000..2df177f7e --- /dev/null +++ b/lib/RoadizSolrBundle/config/packages/roadiz_solr.yaml @@ -0,0 +1,4 @@ +roadiz_solr: + search: + fuzzy_proximity: 2 + fuzzy_min_term_length: 3 diff --git a/lib/RoadizSolrBundle/config/services.yaml b/lib/RoadizSolrBundle/config/services.yaml index e8c6419bd..f141f95e1 100644 --- a/lib/RoadizSolrBundle/config/services.yaml +++ b/lib/RoadizSolrBundle/config/services.yaml @@ -21,6 +21,8 @@ services: $solrHostname: '%env(string:SOLR_HOST)%' $solrPort: '%env(int:SOLR_PORT)%' $solrSecure: '%env(bool:SOLR_SECURE)%' + $fuzzyProximity: '%roadiz_solr.search.fuzzy_proximity%' + $fuzzyMinTermLength: '%roadiz_solr.search.fuzzy_min_term_length%' RZ\Roadiz\SolrBundle\: resource: '../src/' diff --git a/lib/RoadizSolrBundle/src/AbstractSearchHandler.php b/lib/RoadizSolrBundle/src/AbstractSearchHandler.php index f67256092..fbee2bf7e 100644 --- a/lib/RoadizSolrBundle/src/AbstractSearchHandler.php +++ b/lib/RoadizSolrBundle/src/AbstractSearchHandler.php @@ -34,6 +34,8 @@ public function __construct( protected readonly ObjectManager $em, protected readonly LoggerInterface $searchEngineLogger, protected readonly EventDispatcherInterface $eventDispatcher, + protected readonly int $fuzzyProximity, + protected readonly int $fuzzyMinTermLength, ) { } @@ -250,10 +252,10 @@ protected function getFormattedQuery(string $q): array $fuzzyiedQuery = implode(' ', array_map(function (string $word) { /* * Do not fuzz short words: Solr crashes - * Proximity is set to 1 by default for single-words + * Proximity is configurable and can be disabled. */ - if (\mb_strlen($word) > 3) { - return $this->escapeQuery($word).'~2'; + if ($this->shouldFuzzify($word)) { + return $this->escapeQuery($word).$this->getFuzzySuffix(); } return $this->escapeQuery($word); @@ -265,7 +267,10 @@ protected function getFormattedQuery(string $q): array /* * Wildcard search for allowing autocomplete */ - $wildcardQuery = $this->escapeQuery($q).'*~2'; + $wildcardQuery = $this->escapeQuery($q).'*'; + if ($this->shouldFuzzify($q)) { + $wildcardQuery .= $this->getFuzzySuffix(); + } return [$exactQuery, $fuzzyiedQuery, $wildcardQuery]; } @@ -297,29 +302,43 @@ protected function buildQuery(string $q, array &$args, bool $searchTags = false) $exactQuery, $fuzzyiedQuery ); - } else { - return sprintf( - '('.$titleField.':%s)^10 ('.$titleField.':%s) ('.$titleField.':%s) ('.$collectionField.':%s)^2 ('.$collectionField.':%s)', - $exactQuery, - $fuzzyiedQuery, - $wildcardQuery, - $exactQuery, - $fuzzyiedQuery - ); } + + return sprintf( + '('.$titleField.':%s)^10 ('.$titleField.':%s) ('.$titleField.':%s) ('.$collectionField.':%s)^2 ('.$collectionField.':%s)', + $exactQuery, + $fuzzyiedQuery, + $wildcardQuery, + $exactQuery, + $fuzzyiedQuery + ); } protected function buildHighlightingQuery(string $q): string { $q = trim($q); $words = preg_split('#[\s,]+#', $q, -1, PREG_SPLIT_NO_EMPTY); - if (\is_array($words) && \count($words) > 1) { + if (!\is_array($words) || \count($words) > 1) { return $this->escapeQuery($q); } - $q = $this->escapeQuery($q); + $escapedQuery = $this->escapeQuery($q); + if (!$this->shouldFuzzify($q)) { + return $escapedQuery; + } + + return $escapedQuery.$this->getFuzzySuffix(); + } + + private function shouldFuzzify(string $word): bool + { + return $this->fuzzyProximity > 0 + && \mb_strlen($word) >= $this->fuzzyMinTermLength; + } - return sprintf('%s~2', $q); + private function getFuzzySuffix(): string + { + return '~'.$this->fuzzyProximity; } protected function buildQueryFields(array &$args, bool $searchTags = true): string diff --git a/lib/RoadizSolrBundle/src/DependencyInjection/Configuration.php b/lib/RoadizSolrBundle/src/DependencyInjection/Configuration.php new file mode 100644 index 000000000..004d40736 --- /dev/null +++ b/lib/RoadizSolrBundle/src/DependencyInjection/Configuration.php @@ -0,0 +1,39 @@ +getRootNode(); + + $root + ->addDefaultsIfNotSet() + ->children() + ->arrayNode('search') + ->addDefaultsIfNotSet() + ->children() + ->integerNode('fuzzy_proximity') + ->defaultValue(2) + ->min(0) + ->max(2) + ->end() + ->integerNode('fuzzy_min_term_length') + ->defaultValue(3) + ->min(0) + ->end() + ->end() + ->end() + ->end(); + + return $builder; + } +} diff --git a/lib/RoadizSolrBundle/src/DependencyInjection/RoadizSolrExtension.php b/lib/RoadizSolrBundle/src/DependencyInjection/RoadizSolrExtension.php index d9af6e86e..5c9e3392d 100644 --- a/lib/RoadizSolrBundle/src/DependencyInjection/RoadizSolrExtension.php +++ b/lib/RoadizSolrBundle/src/DependencyInjection/RoadizSolrExtension.php @@ -20,7 +20,48 @@ public function getAlias(): string #[\Override] public function load(array $configs, ContainerBuilder $container): void { + $config = $this->processConfiguration(new Configuration(), $configs); + $loader = new YamlFileLoader($container, new FileLocator(dirname(__DIR__).'/../config')); $loader->load('services.yaml'); + + $fuzzySearchConfig = $this->resolveFuzzySearchConfig($configs, $config, $container); + $container->setParameter('roadiz_solr.search.fuzzy_proximity', $fuzzySearchConfig['fuzzy_proximity']); + $container->setParameter('roadiz_solr.search.fuzzy_min_term_length', $fuzzySearchConfig['fuzzy_min_term_length']); + } + + /** + * @return array{fuzzy_proximity: mixed, fuzzy_min_term_length: mixed} + */ + private function resolveFuzzySearchConfig(array $configs, array $config, ContainerBuilder $container): array + { + $hasRoadizSolrFuzzyProximity = false; + $hasRoadizSolrFuzzyMinTermLength = false; + + foreach ($configs as $singleConfig) { + if (isset($singleConfig['search']['fuzzy_proximity'])) { + $hasRoadizSolrFuzzyProximity = true; + } + if (isset($singleConfig['search']['fuzzy_min_term_length'])) { + $hasRoadizSolrFuzzyMinTermLength = true; + } + } + + $fuzzyProximity = $hasRoadizSolrFuzzyProximity ? $config['search']['fuzzy_proximity'] : null; + $fuzzyMinTermLength = $hasRoadizSolrFuzzyMinTermLength ? $config['search']['fuzzy_min_term_length'] : null; + + foreach ($container->getExtensionConfig('roadiz_core') as $legacyConfig) { + if (null === $fuzzyProximity && isset($legacyConfig['solr']['search']['fuzzy_proximity'])) { + $fuzzyProximity = $legacyConfig['solr']['search']['fuzzy_proximity']; + } + if (null === $fuzzyMinTermLength && isset($legacyConfig['solr']['search']['fuzzy_min_term_length'])) { + $fuzzyMinTermLength = $legacyConfig['solr']['search']['fuzzy_min_term_length']; + } + } + + return [ + 'fuzzy_proximity' => $fuzzyProximity ?? $config['search']['fuzzy_proximity'], + 'fuzzy_min_term_length' => $fuzzyMinTermLength ?? $config['search']['fuzzy_min_term_length'], + ]; } } diff --git a/lib/RoadizSolrBundle/src/Solarium/AbstractSolarium.php b/lib/RoadizSolrBundle/src/Solarium/AbstractSolarium.php index 1837b7f49..d2f2ebfd0 100644 --- a/lib/RoadizSolrBundle/src/Solarium/AbstractSolarium.php +++ b/lib/RoadizSolrBundle/src/Solarium/AbstractSolarium.php @@ -141,9 +141,9 @@ public function remove(Query $update): bool $update->addDeleteById($this->document->id); return true; - } else { - return false; } + + return false; } /** @@ -248,12 +248,11 @@ public function getDocumentFromIndex(): bool if (0 === $resultset->getNumFound()) { return false; - } else { - foreach ($resultset as $document) { - $this->document = $document; + } + foreach ($resultset as $document) { + $this->document = $document; - return true; - } + return true; } return false; diff --git a/lib/RoadizTwoFactorBundle/src/Backup/BackupCodeManager.php b/lib/RoadizTwoFactorBundle/src/Backup/BackupCodeManager.php index 05b8b8914..2d82fbbdb 100644 --- a/lib/RoadizTwoFactorBundle/src/Backup/BackupCodeManager.php +++ b/lib/RoadizTwoFactorBundle/src/Backup/BackupCodeManager.php @@ -39,7 +39,7 @@ public function invalidateBackupCode(object $user, string $code): void $user = $this->twoFactorUserProvider->getFromUser($user); } - if (!($user instanceof BackupCodeInterface)) { + if (!$user instanceof BackupCodeInterface) { return; } diff --git a/lib/RoadizTwoFactorBundle/src/Controller/BackupCodesAdminController.php b/lib/RoadizTwoFactorBundle/src/Controller/BackupCodesAdminController.php index d56a8c780..631de46f1 100644 --- a/lib/RoadizTwoFactorBundle/src/Controller/BackupCodesAdminController.php +++ b/lib/RoadizTwoFactorBundle/src/Controller/BackupCodesAdminController.php @@ -29,7 +29,7 @@ public function backupCodesAdminAction(Request $request, TokenStorageInterface $ } $user = $tokenStorage->getToken()->getUser(); - if (!($user instanceof User)) { + if (!$user instanceof User) { throw $this->createAccessDeniedException('You must be logged in to access this page.'); } $twoFactorUser = $this->twoFactorUserProvider->getFromUser($user); diff --git a/lib/RoadizTwoFactorBundle/src/Controller/QrCodeController.php b/lib/RoadizTwoFactorBundle/src/Controller/QrCodeController.php index 82df278e1..6c9452668 100644 --- a/lib/RoadizTwoFactorBundle/src/Controller/QrCodeController.php +++ b/lib/RoadizTwoFactorBundle/src/Controller/QrCodeController.php @@ -37,12 +37,12 @@ public function totpQrCodeAction(TokenStorageInterface $tokenStorage): Response } $user = $tokenStorage->getToken()->getUser(); - if (!($user instanceof User)) { + if (!$user instanceof User) { throw $this->createAccessDeniedException('You must be logged in to access this page.'); } $twoFactorUser = $this->twoFactorUserProvider->getFromUser($user); - if (!($twoFactorUser instanceof TwoFactorInterface)) { + if (!$twoFactorUser instanceof TwoFactorInterface) { throw $this->createNotFoundException('Cannot display QR code'); } diff --git a/lib/RoadizTwoFactorBundle/src/Controller/TwoFactorAdminController.php b/lib/RoadizTwoFactorBundle/src/Controller/TwoFactorAdminController.php index 07d9618c2..2e8a355b5 100644 --- a/lib/RoadizTwoFactorBundle/src/Controller/TwoFactorAdminController.php +++ b/lib/RoadizTwoFactorBundle/src/Controller/TwoFactorAdminController.php @@ -34,7 +34,7 @@ public function twoFactorAdminAction(Request $request, TokenStorageInterface $to } $user = $tokenStorage->getToken()->getUser(); - if (!($user instanceof User)) { + if (!$user instanceof User) { throw $this->createAccessDeniedException('You must be logged in to access this page.'); } $assignation = []; @@ -82,7 +82,7 @@ public function twoFactorDisableAction(Request $request, TokenStorageInterface $ $this->denyAccessUnlessGranted('ROLE_BACKEND_USER'); $user = $tokenStorage->getToken()->getUser(); - if (!($user instanceof User)) { + if (!$user instanceof User) { throw $this->createAccessDeniedException('You must be logged in to access this page.'); } $twoFactorUser = $this->twoFactorUserProvider->getFromUser($user); diff --git a/lib/RoadizTwoFactorBundle/src/Entity/TwoFactorUser.php b/lib/RoadizTwoFactorBundle/src/Entity/TwoFactorUser.php index 300039bf9..1a75cdcc2 100644 --- a/lib/RoadizTwoFactorBundle/src/Entity/TwoFactorUser.php +++ b/lib/RoadizTwoFactorBundle/src/Entity/TwoFactorUser.php @@ -15,11 +15,9 @@ use Scheb\TwoFactorBundle\Model\TrustedDeviceInterface; use Symfony\Component\Validator\Constraints as Assert; -#[ - ORM\Entity(repositoryClass: TwoFactorUserRepository::class), +#[ORM\Entity(repositoryClass: TwoFactorUserRepository::class), ORM\Table(name: 'two_factor_users'), - ORM\UniqueConstraint(columns: ['user_id']), -] + ORM\UniqueConstraint(columns: ['user_id']),] class TwoFactorUser implements TotpTwoFactorInterface, BackupCodeInterface, TrustedDeviceInterface, GoogleAuthenticatorTwoFactorInterface { #[ORM\OneToOne(targetEntity: User::class)] diff --git a/lib/RoadizTwoFactorBundle/src/Security/Provider/AuthenticatorTwoFactorProvider.php b/lib/RoadizTwoFactorBundle/src/Security/Provider/AuthenticatorTwoFactorProvider.php index 917be675b..f0ae934bf 100644 --- a/lib/RoadizTwoFactorBundle/src/Security/Provider/AuthenticatorTwoFactorProvider.php +++ b/lib/RoadizTwoFactorBundle/src/Security/Provider/AuthenticatorTwoFactorProvider.php @@ -26,7 +26,7 @@ public function __construct( public function beginAuthentication(AuthenticationContextInterface $context): bool { $user = $context->getUser(); - if (!($user instanceof User)) { + if (!$user instanceof User) { return false; } @@ -61,7 +61,7 @@ public function validateAuthenticationCode(object $user, string $authenticationC $user = $this->getTwoFactorFromUser($user); } - if (!($user instanceof TwoFactorInterface)) { + if (!$user instanceof TwoFactorInterface) { return false; } diff --git a/lib/RoadizUserBundle/src/Entity/UserValidationToken.php b/lib/RoadizUserBundle/src/Entity/UserValidationToken.php index 129355bd4..79ecd1b14 100644 --- a/lib/RoadizUserBundle/src/Entity/UserValidationToken.php +++ b/lib/RoadizUserBundle/src/Entity/UserValidationToken.php @@ -10,11 +10,9 @@ use Symfony\Component\Security\Core\User\UserInterface; use Symfony\Component\Validator\Constraints as Assert; -#[ - ORM\Table(name: 'user_validation_tokens'), +#[ORM\Table(name: 'user_validation_tokens'), UniqueEntity('token'), - ORM\Entity(repositoryClass: UserValidationTokenRepository::class) -] + ORM\Entity(repositoryClass: UserValidationTokenRepository::class)] class UserValidationToken { #[ORM\Column(name: 'id', type: 'integer')] diff --git a/lib/RoadizUserBundle/src/Manager/UserValidationTokenManager.php b/lib/RoadizUserBundle/src/Manager/UserValidationTokenManager.php index a29f3d3d1..ebde27e19 100644 --- a/lib/RoadizUserBundle/src/Manager/UserValidationTokenManager.php +++ b/lib/RoadizUserBundle/src/Manager/UserValidationTokenManager.php @@ -71,7 +71,7 @@ private function sendUserValidationEmail(UserValidationToken $userValidationToke { $user = $userValidationToken->getUser(); - if (!($user instanceof User)) { + if (!$user instanceof User) { return; } diff --git a/lib/RoadizUserBundle/src/State/UserValidationTokenProcessor.php b/lib/RoadizUserBundle/src/State/UserValidationTokenProcessor.php index 76db89e46..e96747e44 100644 --- a/lib/RoadizUserBundle/src/State/UserValidationTokenProcessor.php +++ b/lib/RoadizUserBundle/src/State/UserValidationTokenProcessor.php @@ -55,7 +55,7 @@ public function process($data, Operation $operation, array $uriVariables = [], a throw new AccessDeniedHttpException('Token does not belong to current account'); } - if (!($user instanceof User)) { + if (!$user instanceof User) { throw new UnprocessableEntityHttpException('User is not a valid user.'); } diff --git a/src/Entity/PositionedPageUser.php b/src/Entity/PositionedPageUser.php index 88963e2f1..81562f8df 100644 --- a/src/Entity/PositionedPageUser.php +++ b/src/Entity/PositionedPageUser.php @@ -12,13 +12,11 @@ use RZ\Roadiz\Core\AbstractEntities\SequentialIdTrait; use RZ\Roadiz\CoreBundle\Entity\User; -#[ - ORM\Entity(), +#[ORM\Entity(), ORM\Table(name: 'positioned_page_user'), ORM\HasLifecycleCallbacks, ORM\Index(columns: ['position'], name: 'ppu_position'), - ORM\Index(columns: ['node_source_id', 'position'], name: 'ppu_node_source_id_position'), -] + ORM\Index(columns: ['node_source_id', 'position'], name: 'ppu_node_source_id_position'),] class PositionedPageUser implements PositionedInterface, PersistableInterface { use SequentialIdTrait; diff --git a/src/TreeWalker/Definition/ArticleFeedBlockDefinition.php b/src/TreeWalker/Definition/ArticleFeedBlockDefinition.php index 56f46bf3a..403c8b217 100644 --- a/src/TreeWalker/Definition/ArticleFeedBlockDefinition.php +++ b/src/TreeWalker/Definition/ArticleFeedBlockDefinition.php @@ -27,7 +27,7 @@ public function isStoppingCollectionOnceInvoked(): bool */ public function __invoke(NodesSources $source, WalkerInterface $walker): array { - if (!($this->context instanceof NodeSourceWalkerContext)) { + if (!$this->context instanceof NodeSourceWalkerContext) { throw new \InvalidArgumentException('Context should be instance of '.NodeSourceWalkerContext::class); }