11<?php
22
3+ /*
4+ * This file is part of the Silverback API Components Bundle Project
5+ *
6+ * (c) Daniel West <daniel@silverback.is>
7+ *
8+ * For the full copyright and license information, please view the LICENSE
9+ * file that was distributed with this source code.
10+ */
11+
12+ declare (strict_types=1 );
13+
314namespace Silverback \ApiComponentsBundle \EventListener \Doctrine ;
415
516use ApiPlatform \Api \IriConverterInterface ;
819use ApiPlatform \Exception \InvalidArgumentException ;
920use ApiPlatform \Metadata \GetCollection ;
1021use Doctrine \Common \Util \ClassUtils ;
11- use Doctrine \DBAL \Platforms \SqlitePlatform ;
1222use Doctrine \ORM \EntityRepository ;
1323use Doctrine \ORM \Event \OnFlushEventArgs ;
1424use Doctrine \ORM \Event \PostFlushEventArgs ;
15- use Doctrine \ORM \Event \PreFlushEventArgs ;
1625use Doctrine \ORM \PersistentCollection ;
1726use Doctrine \ORM \UnitOfWork ;
1827use Doctrine \Persistence \ManagerRegistry ;
1928use Doctrine \Persistence \ObjectManager ;
2029use Doctrine \Persistence \ObjectRepository ;
2130use Silverback \ApiComponentsBundle \DataProvider \PageDataProvider ;
2231use Silverback \ApiComponentsBundle \Entity \Component \Collection ;
23- use Silverback \ApiComponentsBundle \Entity \Core \Page ;
2432use Silverback \ApiComponentsBundle \Entity \Core \PageDataInterface ;
2533use Silverback \ApiComponentsBundle \HttpCache \ResourceChangedPropagatorInterface ;
2634use Silverback \ApiComponentsBundle \Repository \Core \ComponentPositionRepository ;
@@ -36,12 +44,7 @@ class PropagateUpdatesListener
3644 private array $ updatedCollectionClassToIriMapping = [];
3745
3846 /**
39- * @param IriConverterInterface $iriConverter
40- * @param ManagerRegistry $entityManager
4147 * @param iterable|ResourceChangedPropagatorInterface[] $resourceChangedPropagators
42- * @param ResourceClassResolverInterface $resourceClassResolver
43- * @param PageDataProvider $pageDataProvider
44- * @param ComponentPositionRepository $positionRepository
4548 */
4649 public function __construct (
4750 private readonly IriConverterInterface $ iriConverter ,
@@ -90,7 +93,7 @@ private function collectUpdatedPageDataAndPositions(): void
9093 $ pageDataComponentMetadata = $ this ->pageDataProvider ->findPageDataComponentMetadata ($ updatedResource );
9194 foreach ($ pageDataComponentMetadata as $ pageDataComponentMetadatum ) {
9295 $ pageDataResources = $ pageDataComponentMetadatum ->getPageDataResources ();
93- if (count ($ pageDataResources )) {
96+ if (\ count ($ pageDataResources )) {
9497 foreach ($ pageDataResources as $ pageDataResource ) {
9598 $ this ->collectUpdatedResource ($ pageDataResource , 'updated ' );
9699 $ this ->addToPropagators ($ pageDataResource , 'updated ' );
@@ -191,7 +194,7 @@ private function addResourceIrisFromObject($resource, string $type): void
191194 {
192195 if (
193196 isset ($ this ->updatedResources [$ resource ]) &&
194- $ type !== ' deleted '
197+ ' deleted ' !== $ type
195198 ) {
196199 return ;
197200 }
@@ -226,7 +229,7 @@ private function collectDynamicComponentPositionResources(array $pageDataPropert
226229 if (!$ pageDataPropertiesChanged ) {
227230 $ pageDataPropertiesChanged = $ this ->pageDataPropertiesChanged ;
228231 }
229- if (0 === count ($ pageDataPropertiesChanged )) {
232+ if (0 === \ count ($ pageDataPropertiesChanged )) {
230233 return ;
231234 }
232235 $ positions = $ this ->positionRepository ->findByPageDataProperties ($ pageDataPropertiesChanged );
0 commit comments