diff --git a/composer.json b/composer.json index a925fdd5..dfc00065 100644 --- a/composer.json +++ b/composer.json @@ -33,6 +33,7 @@ "ext-json": "*", "ext-openssl": "*", "ext-simplexml": "*", + "ext-mbstring": "*", "ext-zip": "*", "api-platform/core": "~3.2.14", "codercat/jwk-to-pem": "^1.0", diff --git a/lib/RoadizCoreBundle/composer.json b/lib/RoadizCoreBundle/composer.json index 5dc81bc4..4d718e46 100644 --- a/lib/RoadizCoreBundle/composer.json +++ b/lib/RoadizCoreBundle/composer.json @@ -23,6 +23,7 @@ "ext-iconv": "*", "ext-zip": "*", "ext-json": "*", + "ext-mbstring": "*", "api-platform/core": "~3.2.14", "doctrine/annotations": "^1.0", "doctrine/doctrine-bundle": "^2.8.1", diff --git a/lib/RoadizCoreBundle/src/Api/ListManager/SolrPaginator.php b/lib/RoadizCoreBundle/src/Api/ListManager/SolrPaginator.php index 8eedf602..a1f1e78b 100644 --- a/lib/RoadizCoreBundle/src/Api/ListManager/SolrPaginator.php +++ b/lib/RoadizCoreBundle/src/Api/ListManager/SolrPaginator.php @@ -5,19 +5,13 @@ namespace RZ\Roadiz\CoreBundle\Api\ListManager; use ApiPlatform\State\Pagination\PaginatorInterface; -use Doctrine\Common\Collections\ArrayCollection; final class SolrPaginator implements PaginatorInterface, \IteratorAggregate { private bool $handled = false; - private SolrSearchListManager $listManager; - /** - * @param SolrSearchListManager $listManager - */ - public function __construct(SolrSearchListManager $listManager) + public function __construct(private readonly SolrSearchListManager $listManager) { - $this->listManager = $listManager; } protected function handleOnce(): void diff --git a/lib/RoadizCoreBundle/src/Api/ListManager/SolrSearchListManager.php b/lib/RoadizCoreBundle/src/Api/ListManager/SolrSearchListManager.php index d4c6e75f..871e5587 100644 --- a/lib/RoadizCoreBundle/src/Api/ListManager/SolrSearchListManager.php +++ b/lib/RoadizCoreBundle/src/Api/ListManager/SolrSearchListManager.php @@ -11,25 +11,19 @@ final class SolrSearchListManager extends AbstractEntityListManager { - protected SearchHandlerInterface $searchHandler; protected ?SearchResultsInterface $searchResults; - private array $criteria; - private bool $searchInTags; private ?string $query = null; public function __construct( ?Request $request, - SearchHandlerInterface $searchHandler, - array $criteria = [], - bool $searchInTags = true + private readonly SearchHandlerInterface $searchHandler, + private readonly array $criteria = [], + private readonly bool $searchInTags = true ) { parent::__construct($request); - $this->searchHandler = $searchHandler; - $this->criteria = $criteria; - $this->searchInTags = $searchInTags; } - public function handle(bool $disabled = false) + public function handle(bool $disabled = false): void { if ($this->request === null) { throw new \InvalidArgumentException('Cannot handle a NULL request.'); diff --git a/lib/RoadizCoreBundle/src/Explorer/AbstractDoctrineExplorerProvider.php b/lib/RoadizCoreBundle/src/Explorer/AbstractDoctrineExplorerProvider.php index ce57dc48..c59189e0 100644 --- a/lib/RoadizCoreBundle/src/Explorer/AbstractDoctrineExplorerProvider.php +++ b/lib/RoadizCoreBundle/src/Explorer/AbstractDoctrineExplorerProvider.php @@ -54,6 +54,7 @@ protected function doFetchItems(array $options = []): EntityListManagerInterface $this->configureOptions($resolver); $this->options = $resolver->resolve($options); + /** @var EntityListManager $listManager */ $listManager = new EntityListManager( $this->requestStack->getCurrentRequest(), $this->managerRegistry->getManager(), diff --git a/lib/RoadizCoreBundle/src/ListManager/AbstractEntityListManager.php b/lib/RoadizCoreBundle/src/ListManager/AbstractEntityListManager.php index 128c964c..6e9a7500 100644 --- a/lib/RoadizCoreBundle/src/ListManager/AbstractEntityListManager.php +++ b/lib/RoadizCoreBundle/src/ListManager/AbstractEntityListManager.php @@ -8,7 +8,6 @@ abstract class AbstractEntityListManager implements EntityListManagerInterface { - protected ?Request $request = null; protected bool $pagination = true; protected ?array $queryArray = null; protected ?int $currentPage = null; @@ -19,12 +18,8 @@ abstract class AbstractEntityListManager implements EntityListManagerInterface protected bool $allowRequestSorting = true; protected bool $allowRequestSearching = true; - /** - * @param Request|null $request - */ - public function __construct(?Request $request) + public function __construct(protected readonly ?Request $request = null) { - $this->request = $request; $this->displayNotPublishedNodes = false; $this->displayAllNodesStatuses = false; if (null !== $request) { @@ -35,13 +30,13 @@ public function __construct(?Request $request) $this->itemPerPage = static::ITEM_PER_PAGE; } - public function setAllowRequestSorting(bool $allowRequestSorting) + public function setAllowRequestSorting(bool $allowRequestSorting): self { $this->allowRequestSorting = $allowRequestSorting; return $this; } - public function setAllowRequestSearching(bool $allowRequestSearching) + public function setAllowRequestSearching(bool $allowRequestSearching): self { $this->allowRequestSearching = $allowRequestSearching; return $this; @@ -55,11 +50,7 @@ public function isDisplayingNotPublishedNodes(): bool return $this->displayNotPublishedNodes; } - /** - * @param bool $displayNotPublishedNodes - * @return EntityListManagerInterface - */ - public function setDisplayingNotPublishedNodes(bool $displayNotPublishedNodes) + public function setDisplayingNotPublishedNodes(bool $displayNotPublishedNodes): self { $this->displayNotPublishedNodes = $displayNotPublishedNodes; return $this; @@ -76,11 +67,8 @@ public function isDisplayingAllNodesStatuses(): bool /** * Switch repository to disable any security on Node status. To use ONLY in order to * view deleted and archived nodes. - * - * @param bool $displayAllNodesStatuses - * @return EntityListManagerInterface */ - public function setDisplayingAllNodesStatuses(bool $displayAllNodesStatuses) + public function setDisplayingAllNodesStatuses(bool $displayAllNodesStatuses): self { $this->displayAllNodesStatuses = $displayAllNodesStatuses; return $this; @@ -89,7 +77,7 @@ public function setDisplayingAllNodesStatuses(bool $displayAllNodesStatuses) /** * @inheritDoc */ - public function setPage(int $page) + public function setPage(int $page): self { if ($page < 1) { throw new \RuntimeException("Page cannot be lesser than 1.", 1); @@ -107,19 +95,13 @@ protected function getPage(): int return $this->currentPage; } - /** - * @return EntityListManagerInterface - */ - public function enablePagination() + public function enablePagination(): self { $this->pagination = true; return $this; } - /** - * @inheritDoc - */ - public function disablePagination() + public function disablePagination(): self { $this->setPage(1); $this->pagination = false; @@ -192,12 +174,8 @@ protected function getItemPerPage(): int /** * Configure a custom item count per page. - * - * @param int $itemPerPage - * - * @return EntityListManagerInterface */ - public function setItemPerPage(int $itemPerPage) + public function setItemPerPage(int $itemPerPage): self { if ($itemPerPage < 1) { throw new \RuntimeException("Item count per page cannot be lesser than 1.", 1); diff --git a/lib/RoadizCoreBundle/src/ListManager/EntityListManager.php b/lib/RoadizCoreBundle/src/ListManager/EntityListManager.php index f46adaa8..74eec683 100644 --- a/lib/RoadizCoreBundle/src/ListManager/EntityListManager.php +++ b/lib/RoadizCoreBundle/src/ListManager/EntityListManager.php @@ -10,46 +10,41 @@ use RZ\Roadiz\Core\AbstractEntities\TranslationInterface; use RZ\Roadiz\CoreBundle\Entity\Node; use RZ\Roadiz\CoreBundle\Entity\NodesSources; -use RZ\Roadiz\CoreBundle\Entity\NodeType; use RZ\Roadiz\CoreBundle\Repository\NodeRepository; use RZ\Roadiz\CoreBundle\Repository\StatusAwareRepository; +use Symfony\Component\DependencyInjection\Attribute\Exclude; use Symfony\Component\HttpFoundation\Request; /** * Perform basic filtering and search over entity listings. + * + * @template T of PersistableInterface */ +#[Exclude] class EntityListManager extends AbstractEntityListManager { /** - * @var class-string + * @var Paginator|null */ - protected string $entityName; - protected ObjectManager $entityManager; protected ?Paginator $paginator = null; - protected ?array $orderingArray = null; - protected ?array $filteringArray = null; protected ?array $assignation = null; protected ?TranslationInterface $translation = null; /** * @param Request|null $request * @param ObjectManager $entityManager - * @param class-string $entityName - * @param array $preFilters - * @param array $preOrdering + * @param class-string $entityName + * @param array $filteringArray + * @param array $orderingArray */ public function __construct( ?Request $request, - ObjectManager $entityManager, - string $entityName, - array $preFilters = [], - array $preOrdering = [] + protected readonly ObjectManager $entityManager, + protected readonly string $entityName, + protected array $filteringArray = [], + protected array $orderingArray = [] ) { parent::__construct($request); - $this->entityName = $entityName; - $this->entityManager = $entityManager; - $this->orderingArray = $preOrdering; - $this->filteringArray = $preFilters; $this->assignation = []; } @@ -65,7 +60,7 @@ public function getTranslation(): ?TranslationInterface * @param TranslationInterface|null $translation * @return $this */ - public function setTranslation(TranslationInterface $translation = null) + public function setTranslation(TranslationInterface $translation = null): self { $this->translation = $translation; @@ -77,8 +72,9 @@ public function setTranslation(TranslationInterface $translation = null) * * @param bool $disabled Disable pagination and filtering over GET params * @return void + * @throws \ReflectionException */ - public function handle(bool $disabled = false) + public function handle(bool $disabled = false): void { // transform the key chroot in parent if (array_key_exists('chroot', $this->filteringArray)) { @@ -142,14 +138,15 @@ protected function handleOrderingParam(string $field, string $ordering): void } + /** + * @throws \ReflectionException + */ protected function createPaginator(): void { - if ( - $this->entityName === Node::class || - $this->entityName === 'RZ\Roadiz\CoreBundle\Entity\Node' || - $this->entityName === '\RZ\Roadiz\CoreBundle\Entity\Node' || - $this->entityName === "Node" - ) { + $reflectionClass = new \ReflectionClass($this->entityName); + + if ($this->entityName === Node::class) { + // @phpstan-ignore-next-line $this->paginator = new NodePaginator( $this->entityManager, $this->entityName, @@ -158,14 +155,13 @@ protected function createPaginator(): void ); $this->paginator->setTranslation($this->translation); } elseif ( - $this->entityName == NodesSources::class || - $this->entityName == 'RZ\Roadiz\CoreBundle\Entity\NodesSources' || - $this->entityName == '\RZ\Roadiz\CoreBundle\Entity\NodesSources' || - $this->entityName == "NodesSources" || - str_contains($this->entityName, NodeType::getGeneratedEntitiesNamespace()) + $this->entityName === NodesSources::class || + $reflectionClass->isSubclassOf(NodesSources::class) ) { + // @phpstan-ignore-next-line $this->paginator = new NodesSourcesPaginator( $this->entityManager, + // @phpstan-ignore-next-line $this->entityName, $this->itemPerPage, $this->filteringArray @@ -216,7 +212,7 @@ public function getPageCount(): int /** * Return filtered entities. * - * @return array|DoctrinePaginator + * @return array|DoctrinePaginator */ public function getEntities(): array|DoctrinePaginator { diff --git a/lib/RoadizCoreBundle/src/ListManager/EntityListManagerInterface.php b/lib/RoadizCoreBundle/src/ListManager/EntityListManagerInterface.php index 4b5c3551..81131599 100644 --- a/lib/RoadizCoreBundle/src/ListManager/EntityListManagerInterface.php +++ b/lib/RoadizCoreBundle/src/ListManager/EntityListManagerInterface.php @@ -4,6 +4,8 @@ namespace RZ\Roadiz\CoreBundle\ListManager; +use Doctrine\ORM\Tools\Pagination\Paginator as DoctrinePaginator; + interface EntityListManagerInterface { public const ITEM_PER_PAGE = 20; @@ -12,13 +14,13 @@ interface EntityListManagerInterface * @param bool $allowRequestSorting * @return $this */ - public function setAllowRequestSorting(bool $allowRequestSorting); + public function setAllowRequestSorting(bool $allowRequestSorting): self; /** * @param bool $allowRequestSearching * @return $this */ - public function setAllowRequestSearching(bool $allowRequestSearching); + public function setAllowRequestSearching(bool $allowRequestSearching): self; /** * @return bool @@ -29,7 +31,7 @@ public function isDisplayingNotPublishedNodes(): bool; * @param bool $displayNotPublishedNodes * @return EntityListManagerInterface */ - public function setDisplayingNotPublishedNodes(bool $displayNotPublishedNodes); + public function setDisplayingNotPublishedNodes(bool $displayNotPublishedNodes): self; /** * @return bool @@ -43,7 +45,7 @@ public function isDisplayingAllNodesStatuses(): bool; * @param bool $displayAllNodesStatuses * @return EntityListManagerInterface */ - public function setDisplayingAllNodesStatuses(bool $displayAllNodesStatuses); + public function setDisplayingAllNodesStatuses(bool $displayAllNodesStatuses): self; /** * Handle request to find filter to apply to entity listing. @@ -51,7 +53,7 @@ public function setDisplayingAllNodesStatuses(bool $displayAllNodesStatuses); * @param bool $disabled Disable pagination and filtering over GET params * @return void */ - public function handle(bool $disabled = false); + public function handle(bool $disabled = false): void; /** * Configure a custom current page. @@ -60,12 +62,12 @@ public function handle(bool $disabled = false); * * @return EntityListManagerInterface */ - public function setPage(int $page); + public function setPage(int $page): self; /** * @return EntityListManagerInterface */ - public function disablePagination(); + public function disablePagination(): self; /** * Get Twig assignation to render list details. @@ -102,9 +104,9 @@ public function getPageCount(): int; /** * Return filtered entities. * - * @return array|\Doctrine\ORM\Tools\Pagination\Paginator + * @return array|DoctrinePaginator */ - public function getEntities(); + public function getEntities(): array|DoctrinePaginator; /** * Configure a custom item count per page. @@ -113,5 +115,5 @@ public function getEntities(); * * @return EntityListManagerInterface */ - public function setItemPerPage(int $itemPerPage); + public function setItemPerPage(int $itemPerPage): self; } diff --git a/lib/RoadizCoreBundle/src/ListManager/NodePaginator.php b/lib/RoadizCoreBundle/src/ListManager/NodePaginator.php index 3f8813fa..c625c23e 100644 --- a/lib/RoadizCoreBundle/src/ListManager/NodePaginator.php +++ b/lib/RoadizCoreBundle/src/ListManager/NodePaginator.php @@ -4,50 +4,41 @@ namespace RZ\Roadiz\CoreBundle\ListManager; +use Doctrine\ORM\Tools\Pagination\Paginator as DoctrinePaginator; use RZ\Roadiz\Core\AbstractEntities\TranslationInterface; +use RZ\Roadiz\CoreBundle\Entity\Node; use RZ\Roadiz\CoreBundle\Repository\NodeRepository; +use Symfony\Component\DependencyInjection\Attribute\Exclude; /** * A paginator class to filter node entities with limit and search. * * This class add some translation and security filters + * + * @extends Paginator */ +#[Exclude] class NodePaginator extends Paginator { protected ?TranslationInterface $translation = null; - /** - * @return TranslationInterface|null - */ - public function getTranslation() + public function getTranslation(): ?TranslationInterface { return $this->translation; } - /** - * @param TranslationInterface|null $translation - * - * @return $this - */ - public function setTranslation(TranslationInterface $translation = null) + public function setTranslation(TranslationInterface $translation = null): self { $this->translation = $translation; return $this; } - /** - * Return entities filtered for current page. - * - * @param array $order - * @param int $page - * - * @return array|\Doctrine\ORM\Tools\Pagination\Paginator - */ - public function findByAtPage(array $order = [], int $page = 1) + public function findByAtPage(array $order = [], int $page = 1): array|DoctrinePaginator { if (null !== $this->searchPattern) { return $this->searchByAtPage($order, $page); } else { + /** @var NodeRepository $repository */ $repository = $this->getRepository(); if ($repository instanceof NodeRepository) { return $repository->findBy( @@ -67,9 +58,6 @@ public function findByAtPage(array $order = [], int $page = 1) } } - /** - * @return int - */ public function getTotalCount(): int { if (null === $this->totalCount) { diff --git a/lib/RoadizCoreBundle/src/ListManager/NodesSourcesPaginator.php b/lib/RoadizCoreBundle/src/ListManager/NodesSourcesPaginator.php index c6c746ff..a8aae6f6 100644 --- a/lib/RoadizCoreBundle/src/ListManager/NodesSourcesPaginator.php +++ b/lib/RoadizCoreBundle/src/ListManager/NodesSourcesPaginator.php @@ -4,11 +4,18 @@ namespace RZ\Roadiz\CoreBundle\ListManager; +use Doctrine\ORM\Tools\Pagination\Paginator as DoctrinePaginator; +use RZ\Roadiz\CoreBundle\Entity\NodesSources; +use Symfony\Component\DependencyInjection\Attribute\Exclude; + /** * A paginator class to filter node-sources entities with limit and search. * - * This class add authorizationChecker filters + * This class add authorizationChecker filters. + * + * @extends Paginator */ +#[Exclude] class NodesSourcesPaginator extends Paginator { /** @@ -27,15 +34,7 @@ public function getTotalCount(): int return $this->totalCount; } - /** - * Return entities filtered for current page. - * - * @param array $order - * @param integer $page - * - * @return array|\Doctrine\ORM\Tools\Pagination\Paginator - */ - public function findByAtPage(array $order = [], int $page = 1) + public function findByAtPage(array $order = [], int $page = 1): array|DoctrinePaginator { if (null !== $this->searchPattern) { return $this->searchByAtPage($order, $page); diff --git a/lib/RoadizCoreBundle/src/ListManager/Paginator.php b/lib/RoadizCoreBundle/src/ListManager/Paginator.php index 2c22e542..3c06fc7e 100644 --- a/lib/RoadizCoreBundle/src/ListManager/Paginator.php +++ b/lib/RoadizCoreBundle/src/ListManager/Paginator.php @@ -8,44 +8,39 @@ use Doctrine\ORM\NonUniqueResultException; use Doctrine\ORM\NoResultException; use Doctrine\ORM\QueryBuilder; +use Doctrine\ORM\Tools\Pagination\Paginator as DoctrinePaginator; use Doctrine\Persistence\ObjectManager; +use RZ\Roadiz\Core\AbstractEntities\PersistableInterface; use RZ\Roadiz\CoreBundle\Repository\EntityRepository; use RZ\Roadiz\CoreBundle\Repository\StatusAwareRepository; +use Symfony\Component\DependencyInjection\Attribute\Exclude; /** * A simple paginator class to filter entities with limit and search. + * + * @template T of PersistableInterface */ +#[Exclude] class Paginator { - protected int $itemsPerPage; protected ?int $itemCount = null; - /** - * @var class-string - */ - protected string $entityName; - protected array $criteria; protected ?string $searchPattern = null; - protected ObjectManager $em; protected ?int $totalCount = null; protected bool $displayNotPublishedNodes; protected bool $displayAllNodesStatuses; /** * @param ObjectManager $em - * @param class-string $entityName - * @param int $itemPerPages + * @param class-string $entityName + * @param int $itemsPerPage * @param array $criteria */ public function __construct( - ObjectManager $em, - string $entityName, - int $itemPerPages = 10, - array $criteria = [] + protected readonly ObjectManager $em, + protected readonly string $entityName, + protected int $itemsPerPage = 10, + protected readonly array $criteria = [] ) { - $this->em = $em; - $this->entityName = $entityName; - $this->itemsPerPage = $itemPerPages; - $this->criteria = $criteria; $this->displayNotPublishedNodes = false; $this->displayAllNodesStatuses = false; @@ -69,7 +64,7 @@ public function isDisplayingNotPublishedNodes(): bool * @param bool $displayNonPublishedNodes * @return Paginator */ - public function setDisplayingNotPublishedNodes(bool $displayNonPublishedNodes) + public function setDisplayingNotPublishedNodes(bool $displayNonPublishedNodes): Paginator { $this->displayNotPublishedNodes = $displayNonPublishedNodes; return $this; @@ -90,7 +85,7 @@ public function isDisplayingAllNodesStatuses(): bool * @param bool $displayAllNodesStatuses * @return $this */ - public function setDisplayingAllNodesStatuses(bool $displayAllNodesStatuses) + public function setDisplayingAllNodesStatuses(bool $displayAllNodesStatuses): Paginator { $this->displayAllNodesStatuses = $displayAllNodesStatuses; return $this; @@ -109,7 +104,7 @@ public function getSearchPattern(): ?string * * @return $this */ - public function setSearchPattern(?string $searchPattern) + public function setSearchPattern(?string $searchPattern): Paginator { $this->searchPattern = $searchPattern; @@ -168,9 +163,9 @@ public function getPageCount(): int * @param array $order * @param int $page * - * @return array|\Doctrine\ORM\Tools\Pagination\Paginator + * @return array|DoctrinePaginator */ - public function findByAtPage(array $order = [], int $page = 1) + public function findByAtPage(array $order = [], int $page = 1): array|DoctrinePaginator { if (null !== $this->searchPattern) { return $this->searchByAtPage($order, $page); @@ -191,12 +186,13 @@ public function findByAtPage(array $order = [], int $page = 1) * @param array $order * @param int $page * - * @return array|\Doctrine\ORM\Tools\Pagination\Paginator + * @return array|DoctrinePaginator */ - public function searchByAtPage(array $order = [], int $page = 1) + public function searchByAtPage(array $order = [], int $page = 1): array|DoctrinePaginator { $repository = $this->getRepository(); if ($repository instanceof EntityRepository) { + // @phpstan-ignore-next-line return $repository->searchBy( $this->searchPattern, $this->criteria, @@ -268,9 +264,9 @@ protected function getSearchableFields(): array } /** - * @return \Doctrine\ORM\EntityRepository|EntityRepository|StatusAwareRepository + * @return \Doctrine\ORM\EntityRepository */ - protected function getRepository() + protected function getRepository(): \Doctrine\ORM\EntityRepository { $repository = $this->em->getRepository($this->entityName); if ($repository instanceof StatusAwareRepository) { diff --git a/lib/RoadizCoreBundle/src/ListManager/QueryBuilderListManager.php b/lib/RoadizCoreBundle/src/ListManager/QueryBuilderListManager.php index 98f94230..b47737ab 100644 --- a/lib/RoadizCoreBundle/src/ListManager/QueryBuilderListManager.php +++ b/lib/RoadizCoreBundle/src/ListManager/QueryBuilderListManager.php @@ -6,8 +6,10 @@ use Doctrine\ORM\QueryBuilder; use Doctrine\ORM\Tools\Pagination\Paginator; +use Symfony\Component\DependencyInjection\Attribute\Exclude; use Symfony\Component\HttpFoundation\Request; +#[Exclude] class QueryBuilderListManager extends AbstractEntityListManager { protected QueryBuilder $queryBuilder; @@ -59,7 +61,7 @@ protected function handleSearchParam(string $search): void } } - public function handle(bool $disabled = false) + public function handle(bool $disabled = false): void { $this->handleRequestQuery($disabled); } diff --git a/lib/RoadizCoreBundle/src/ListManager/SessionListFilters.php b/lib/RoadizCoreBundle/src/ListManager/SessionListFilters.php index 4e8dc5f7..55c246c7 100644 --- a/lib/RoadizCoreBundle/src/ListManager/SessionListFilters.php +++ b/lib/RoadizCoreBundle/src/ListManager/SessionListFilters.php @@ -4,8 +4,10 @@ namespace RZ\Roadiz\CoreBundle\ListManager; +use Symfony\Component\DependencyInjection\Attribute\Exclude; use Symfony\Component\HttpFoundation\Request; +#[Exclude] class SessionListFilters { public function __construct( diff --git a/lib/RoadizCoreBundle/src/ListManager/TagListManager.php b/lib/RoadizCoreBundle/src/ListManager/TagListManager.php index 4be28eb7..d97593de 100644 --- a/lib/RoadizCoreBundle/src/ListManager/TagListManager.php +++ b/lib/RoadizCoreBundle/src/ListManager/TagListManager.php @@ -7,12 +7,16 @@ use Doctrine\Persistence\ObjectManager; use RZ\Roadiz\CoreBundle\Entity\Tag; use RZ\Roadiz\CoreBundle\Entity\TagTranslation; +use Symfony\Component\DependencyInjection\Attribute\Exclude; use Symfony\Component\HttpFoundation\Request; use Doctrine\ORM\Tools\Pagination\Paginator as DoctrinePaginator; /** * Perform basic filtering and search over entity listings. + * + * @extends EntityListManager */ +#[Exclude] class TagListManager extends EntityListManager { /** diff --git a/lib/RoadizCoreBundle/src/Repository/EntityRepository.php b/lib/RoadizCoreBundle/src/Repository/EntityRepository.php index 1b0e0223..036d2f89 100644 --- a/lib/RoadizCoreBundle/src/Repository/EntityRepository.php +++ b/lib/RoadizCoreBundle/src/Repository/EntityRepository.php @@ -328,7 +328,7 @@ protected function createSearchBy( * @param int|null $offset * @param string $alias * - * @return array|Paginator + * @return array|Paginator * @psalm-return array|Paginator */ public function searchBy( diff --git a/lib/RoadizCoreBundle/src/Repository/NodeRepository.php b/lib/RoadizCoreBundle/src/Repository/NodeRepository.php index 2d298d0b..780f8872 100644 --- a/lib/RoadizCoreBundle/src/Repository/NodeRepository.php +++ b/lib/RoadizCoreBundle/src/Repository/NodeRepository.php @@ -249,35 +249,6 @@ protected function applyTranslationByTag( } } - /** - * Just like the findBy method but with a given Translation - * - * If no translation nor authorizationChecker is given, the vanilla `findBy` - * method will be called instead. - * - * @param array $criteria - * @param array|null $orderBy - * @param int|null $limit - * @param int|null $offset - * @param TranslationInterface|null $translation - * @return array|Paginator - */ - public function findByWithTranslation( - array $criteria, - array $orderBy = null, - ?int $limit = null, - ?int $offset = null, - TranslationInterface $translation = null - ): array|Paginator { - return $this->findBy( - $criteria, - $orderBy, - $limit, - $offset, - $translation - ); - } - /** * Just like the findBy method but with relational criteria. * @@ -308,7 +279,7 @@ public function findByWithTranslation( * @param int|null $limit * @param int|null $offset * @param TranslationInterface|null $translation - * @return array|Paginator + * @return array|Paginator */ public function findBy( array $criteria, diff --git a/lib/Rozier/src/Widgets/AbstractWidget.php b/lib/Rozier/src/Widgets/AbstractWidget.php index a8851a88..f9e48096 100644 --- a/lib/Rozier/src/Widgets/AbstractWidget.php +++ b/lib/Rozier/src/Widgets/AbstractWidget.php @@ -19,8 +19,10 @@ abstract class AbstractWidget { protected ?TranslationInterface $defaultTranslation = null; - public function __construct(protected RequestStack $requestStack, protected ManagerRegistry $managerRegistry) - { + public function __construct( + protected RequestStack $requestStack, + protected ManagerRegistry $managerRegistry + ) { } /** diff --git a/lib/Rozier/src/Widgets/NodeTreeWidget.php b/lib/Rozier/src/Widgets/NodeTreeWidget.php index 36f1c906..eee069c6 100644 --- a/lib/Rozier/src/Widgets/NodeTreeWidget.php +++ b/lib/Rozier/src/Widgets/NodeTreeWidget.php @@ -9,6 +9,7 @@ use RZ\Roadiz\CoreBundle\Entity\Node; use RZ\Roadiz\CoreBundle\Entity\Tag; use RZ\Roadiz\CoreBundle\ListManager\EntityListManager; +use RZ\Roadiz\CoreBundle\ListManager\EntityListManagerInterface; use RZ\Roadiz\CoreBundle\ListManager\SessionListFilters; use Symfony\Component\HttpFoundation\RequestStack; @@ -84,8 +85,9 @@ public function setStackTree(bool $stackTree): NodeTreeWidget /** * Fill twig assignation array with NodeTree entities. + * @throws \ReflectionException */ - protected function getRootListManager(): EntityListManager + protected function getRootListManager(): EntityListManagerInterface { /* * Only use additional criteria for ROOT list-manager @@ -139,13 +141,14 @@ protected function canOrderByParent(Node $parent = null, bool $subRequest = fals * @param Node|null $parent * @param bool $subRequest Default: false * @param array $additionalCriteria Default: [] - * @return EntityListManager + * @return EntityListManagerInterface + * @throws \ReflectionException */ protected function getListManager( Node $parent = null, bool $subRequest = false, array $additionalCriteria = [] - ): EntityListManager { + ): EntityListManagerInterface { $criteria = array_merge($additionalCriteria, [ 'parent' => $parent, 'translation' => $this->translation, @@ -165,8 +168,10 @@ protected function getListManager( ]; $this->canReorder = false; } - /* + /** * Manage get request to filter list + * + * @var EntityListManager $listManager */ $listManager = new EntityListManager( $this->getRequest(), @@ -202,6 +207,7 @@ protected function getListManager( * @param Node|null $parent * @param bool $subRequest Default: false * @return iterable + * @throws \ReflectionException */ public function getChildrenNodes(Node $parent = null, bool $subRequest = false): iterable { @@ -212,6 +218,7 @@ public function getChildrenNodes(Node $parent = null, bool $subRequest = false): * @param Node|null $parent * @param bool $subRequest Default: false * @return iterable + * @throws \ReflectionException */ public function getReachableChildrenNodes(Node $parent = null, bool $subRequest = false): iterable {