From 834f29e51f2f40bfd64b4274a976d4da40795574 Mon Sep 17 00:00:00 2001 From: Redjan Ymeraj Date: Thu, 16 May 2024 12:31:14 +0200 Subject: [PATCH 1/2] Rebase 0.x --- .github/workflows/test-application.yaml | 8 +----- .../ContentMerger/ContentMerger.php | 11 -------- .../Normalizer/DimensionContentNormalizer.php | 2 ++ .../PublishTransitionSubscriber.php | 24 +++++++++++++++-- .../Model/DimensionContentInterface.php | 6 +++++ .../Domain/Model/DimensionContentTrait.php | 16 ++++++++++++ Content/Domain/Model/TemplateInterface.php | 4 +-- Content/Domain/Model/TemplateTrait.php | 5 +--- .../DimensionContentRepositoryInterface.php | 10 +++++++ .../Doctrine/DimensionContentRepository.php | 26 +++++++++++++++++++ .../Doctrine/MetadataLoader.php | 2 ++ .../Sulu/Link/ContentLinkProvider.php | 4 +-- .../Sulu/Sitemap/ContentSitemapProvider.php | 2 +- .../Sulu/Teaser/ContentTeaserProvider.php | 6 ++--- Resources/config/services.xml | 1 + .../Controller/ExampleController.php | 2 ++ .../Entity/ExampleDimensionContent.php | 5 +--- .../Repository/ExampleRepository.php | 2 +- .../Resources/config/lists/examples.xml | 7 +++++ Tests/Application/Kernel.php | 2 +- .../Sitemap/ContentSitemapProviderTest.php | 2 +- .../SmartContent/ContentDataProviderTest.php | 2 +- .../DataMapper/WebspaceDataMapperTest.php | 2 +- .../Sulu/Page/Select/WebspaceSelectTest.php | 4 +-- composer.json | 2 +- phpstan-baseline.neon | 22 ++++++++++++++++ 26 files changed, 133 insertions(+), 46 deletions(-) create mode 100644 phpstan-baseline.neon diff --git a/.github/workflows/test-application.yaml b/.github/workflows/test-application.yaml index 3cd80e9e..439c9606 100644 --- a/.github/workflows/test-application.yaml +++ b/.github/workflows/test-application.yaml @@ -52,12 +52,6 @@ jobs: env: SYMFONY_DEPRECATIONS_HELPER: weak - - php-version: '8.3' - coverage: false - dependency-versions: 'highest' - env: - SYMFONY_DEPRECATIONS_HELPER: weak - services: mysql: image: mysql:5.7 @@ -119,7 +113,7 @@ jobs: - name: Install and configure PHP uses: shivammathur/setup-php@v2 with: - php-version: 8.3 + php-version: 8.0 extensions: ctype, iconv, mysql - name: Install composer dependencies diff --git a/Content/Application/ContentMerger/ContentMerger.php b/Content/Application/ContentMerger/ContentMerger.php index 80a23dc8..508088ba 100644 --- a/Content/Application/ContentMerger/ContentMerger.php +++ b/Content/Application/ContentMerger/ContentMerger.php @@ -17,7 +17,6 @@ use Sulu\Bundle\ContentBundle\Content\Domain\Model\DimensionContentCollectionInterface; use Sulu\Bundle\ContentBundle\Content\Domain\Model\DimensionContentInterface; use Symfony\Component\PropertyAccess\PropertyAccessor; -use Webmozart\Assert\Assert; class ContentMerger implements ContentMergerInterface { @@ -42,13 +41,6 @@ public function __construct( $this->propertyAccessor = $propertyAccessor; } - /** - * @template T of DimensionContentInterface - * - * @param DimensionContentCollectionInterface $dimensionContentCollection - * - * @return T - */ public function merge(DimensionContentCollectionInterface $dimensionContentCollection): DimensionContentInterface { if (!$dimensionContentCollection->count()) { @@ -60,7 +52,6 @@ public function merge(DimensionContentCollectionInterface $dimensionContentColle foreach ($dimensionContentCollection as $dimensionContent) { if (!$mergedDimensionContent) { $contentRichEntity = $dimensionContent->getResource(); - /** @var T $mergedDimensionContent */ $mergedDimensionContent = $contentRichEntity->createDimensionContent(); $mergedDimensionContent->markAsMerged(); } @@ -78,8 +69,6 @@ public function merge(DimensionContentCollectionInterface $dimensionContentColle } } - Assert::notNull($mergedDimensionContent); - return $mergedDimensionContent; } } diff --git a/Content/Application/ContentNormalizer/Normalizer/DimensionContentNormalizer.php b/Content/Application/ContentNormalizer/Normalizer/DimensionContentNormalizer.php index 6a8bae7c..854c0a98 100644 --- a/Content/Application/ContentNormalizer/Normalizer/DimensionContentNormalizer.php +++ b/Content/Application/ContentNormalizer/Normalizer/DimensionContentNormalizer.php @@ -28,6 +28,7 @@ public function getIgnoredAttributes(object $object): array 'merged', 'dimension', 'resource', + 'version', ]; } @@ -40,6 +41,7 @@ public function enhance(object $object, array $normalizedData): array $normalizedData['id'] = $object->getResource()->getId(); $normalizedData['locale'] = $object->getLocale(); $normalizedData['stage'] = $object->getStage(); + $normalizedData['version'] = $object->getVersion(); return $normalizedData; } diff --git a/Content/Application/ContentWorkflow/Subscriber/PublishTransitionSubscriber.php b/Content/Application/ContentWorkflow/Subscriber/PublishTransitionSubscriber.php index 69c89f29..f10f52ef 100644 --- a/Content/Application/ContentWorkflow/Subscriber/PublishTransitionSubscriber.php +++ b/Content/Application/ContentWorkflow/Subscriber/PublishTransitionSubscriber.php @@ -21,6 +21,7 @@ use Sulu\Bundle\ContentBundle\Content\Domain\Model\ShadowInterface; use Sulu\Bundle\ContentBundle\Content\Domain\Model\TemplateInterface; use Sulu\Bundle\ContentBundle\Content\Domain\Model\WorkflowInterface; +use Sulu\Bundle\ContentBundle\Content\Domain\Repository\DimensionContentRepositoryInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\Workflow\Event\TransitionEvent; @@ -36,9 +37,17 @@ class PublishTransitionSubscriber implements EventSubscriberInterface */ private $contentCopier; - public function __construct(ContentCopierInterface $contentCopier) - { + /** + * @var DimensionContentRepositoryInterface + */ + private $dimensionContentRepository; + + public function __construct( + ContentCopierInterface $contentCopier, + DimensionContentRepositoryInterface $dimensionContentRepository + ) { $this->contentCopier = $contentCopier; + $this->dimensionContentRepository = $dimensionContentRepository; } public function onPublish(TransitionEvent $transitionEvent): void @@ -77,6 +86,17 @@ public function onPublish(TransitionEvent $transitionEvent): void $targetDimensionAttributes = $dimensionAttributes; $targetDimensionAttributes['stage'] = DimensionContentInterface::STAGE_LIVE; + $publishLocales = $this->dimensionContentRepository->getLocales($contentRichEntity, $dimensionAttributes); + + foreach ($publishLocales as $publishLocale) { + $this->contentCopier->copy( + $contentRichEntity, + \array_merge($dimensionAttributes, ['locale' => $publishLocale]), + $contentRichEntity, + \array_merge($dimensionAttributes, ['locale' => $publishLocale, 'version' => time()]) + ); + } + $shadowLocale = $dimensionContent instanceof ShadowInterface ? $dimensionContent->getShadowLocale() : null; diff --git a/Content/Domain/Model/DimensionContentInterface.php b/Content/Domain/Model/DimensionContentInterface.php index b40bf166..7da50cb7 100644 --- a/Content/Domain/Model/DimensionContentInterface.php +++ b/Content/Domain/Model/DimensionContentInterface.php @@ -21,6 +21,8 @@ interface DimensionContentInterface public const STAGE_DRAFT = 'draft'; public const STAGE_LIVE = 'live'; + public const DEFAULT_VERSION = 0; + public static function getResourceKey(): string; public function getLocale(): ?string; @@ -59,6 +61,10 @@ public function getStage(): string; */ public function setStage(string $stage): void; + public function setVersion(int $version): void; + + public function getVersion(): int; + /** * @return T */ diff --git a/Content/Domain/Model/DimensionContentTrait.php b/Content/Domain/Model/DimensionContentTrait.php index 4c5614e8..63ad6afd 100644 --- a/Content/Domain/Model/DimensionContentTrait.php +++ b/Content/Domain/Model/DimensionContentTrait.php @@ -35,6 +35,11 @@ trait DimensionContentTrait */ protected $stage = DimensionContentInterface::STAGE_DRAFT; + /** + * @var int + */ + protected $version = DimensionContentInterface::DEFAULT_VERSION; + /** * @var bool */ @@ -114,6 +119,16 @@ public function getStage(): string return $this->stage; } + public function setVersion(int $version): void + { + $this->version = $version; + } + + public function getVersion(): int + { + return $this->version; + } + public function isMerged(): bool { return $this->isMerged; @@ -132,6 +147,7 @@ public static function getDefaultDimensionAttributes(): array return [ 'locale' => null, 'stage' => DimensionContentInterface::STAGE_DRAFT, + 'version' => DimensionContentInterface::DEFAULT_VERSION, ]; } diff --git a/Content/Domain/Model/TemplateInterface.php b/Content/Domain/Model/TemplateInterface.php index 588c7da7..591a85b4 100644 --- a/Content/Domain/Model/TemplateInterface.php +++ b/Content/Domain/Model/TemplateInterface.php @@ -22,12 +22,12 @@ public function getTemplateKey(): ?string; public function setTemplateKey(string $templateKey): void; /** - * @return array + * @return mixed[] */ public function getTemplateData(): array; /** - * @param array $templateData + * @param mixed[] $templateData */ public function setTemplateData(array $templateData): void; } diff --git a/Content/Domain/Model/TemplateTrait.php b/Content/Domain/Model/TemplateTrait.php index 309b1e2f..2bfedc14 100644 --- a/Content/Domain/Model/TemplateTrait.php +++ b/Content/Domain/Model/TemplateTrait.php @@ -24,7 +24,7 @@ trait TemplateTrait private $templateKey; /** - * @var array + * @var mixed[] */ private $templateData = []; @@ -43,9 +43,6 @@ public function getTemplateData(): array return $this->templateData; } - /** - * @param array $templateData - */ public function setTemplateData(array $templateData): void { $this->templateData = $templateData; diff --git a/Content/Domain/Repository/DimensionContentRepositoryInterface.php b/Content/Domain/Repository/DimensionContentRepositoryInterface.php index b0f8743c..7149d43a 100644 --- a/Content/Domain/Repository/DimensionContentRepositoryInterface.php +++ b/Content/Domain/Repository/DimensionContentRepositoryInterface.php @@ -31,4 +31,14 @@ public function load( ContentRichEntityInterface $contentRichEntity, array $dimensionAttributes ): DimensionContentCollectionInterface; + + /** + * @param mixed[] $dimensionAttributes + * + * @return string[] + */ + public function getLocales( + ContentRichEntityInterface $contentRichEntity, + array $dimensionAttributes + ): array; } diff --git a/Content/Infrastructure/Doctrine/DimensionContentRepository.php b/Content/Infrastructure/Doctrine/DimensionContentRepository.php index 3222199e..c2a52965 100644 --- a/Content/Infrastructure/Doctrine/DimensionContentRepository.php +++ b/Content/Infrastructure/Doctrine/DimensionContentRepository.php @@ -66,6 +66,7 @@ public function load( $queryBuilder = $this->entityManager->createQueryBuilder() ->from($dimensionContentClass, 'dimensionContent') ->where('dimensionContent.' . $mappingProperty . ' = :id') + ->andWhere('dimensionContent.version = 0') ->setParameter('id', $contentRichEntity->getId()); $this->dimensionContentQueryEnhancer->addSelects( @@ -84,4 +85,29 @@ public function load( $dimensionContentClass ); } + + public function getLocales( + ContentRichEntityInterface $contentRichEntity, + array $dimensionAttributes + ): array { + $dimensionContentClass = $this->contentMetadataInspector->getDimensionContentClass(\get_class($contentRichEntity)); + $mappingProperty = $this->contentMetadataInspector->getDimensionContentPropertyName(\get_class($contentRichEntity)); + + $queryBuilder = $this->entityManager->createQueryBuilder() + ->from($dimensionContentClass, 'dimensionContent') + ->select('dimensionContent.locale') + ->where('IDENTITY(dimensionContent.' . $mappingProperty . ') = :id') + ->andWhere('dimensionContent.locale IS NOT NULL') + ->setParameter('id', $contentRichEntity->getId()); + + unset($dimensionAttributes['locale']); + foreach ($dimensionAttributes as $key => $value) { + $queryBuilder->andWhere('dimensionContent.' . $key . ' = :' . $key) + ->setParameter(':' . $key, $value); + } + + return \array_map(function($row) { + return $row['locale']; + }, $queryBuilder->getQuery()->getArrayResult()); + } } diff --git a/Content/Infrastructure/Doctrine/MetadataLoader.php b/Content/Infrastructure/Doctrine/MetadataLoader.php index ad58ef6c..39b07339 100644 --- a/Content/Infrastructure/Doctrine/MetadataLoader.php +++ b/Content/Infrastructure/Doctrine/MetadataLoader.php @@ -53,10 +53,12 @@ public function loadClassMetadata(LoadClassMetadataEventArgs $event): void if ($reflection->implementsInterface(DimensionContentInterface::class)) { $this->addField($metadata, 'stage', 'string', ['length' => 16, 'nullable' => false]); $this->addField($metadata, 'locale', 'string', ['length' => 7, 'nullable' => true]); + $this->addField($metadata, 'version', 'integer', ['default' => 0, 'nullable' => true]); $this->addField($metadata, 'ghostLocale', 'string', ['length' => 7, 'nullable' => true]); $this->addField($metadata, 'availableLocales', 'json', ['nullable' => true, 'options' => ['jsonb' => true]]); $this->addIndex($metadata, 'idx_dimension', ['stage', 'locale']); $this->addIndex($metadata, 'idx_locale', ['locale']); + $this->addIndex($metadata, 'idx_version', ['version']); $this->addIndex($metadata, 'idx_stage', ['stage']); } diff --git a/Content/Infrastructure/Sulu/Link/ContentLinkProvider.php b/Content/Infrastructure/Sulu/Link/ContentLinkProvider.php index 42126186..7ee470e8 100644 --- a/Content/Infrastructure/Sulu/Link/ContentLinkProvider.php +++ b/Content/Infrastructure/Sulu/Link/ContentLinkProvider.php @@ -108,9 +108,7 @@ public function preload(array $hrefs, $locale, $published = true): array */ protected function getTitle(DimensionContentInterface $dimensionContent, array $data): ?string { - $title = $data['title'] ?? $data['name'] ?? null; - - return \is_string($title) ? $title : null; + return $data['title'] ?? $data['name'] ?? null; } protected function getEntityIdField(): string diff --git a/Content/Infrastructure/Sulu/Sitemap/ContentSitemapProvider.php b/Content/Infrastructure/Sulu/Sitemap/ContentSitemapProvider.php index 234ae3eb..e9010ba8 100644 --- a/Content/Infrastructure/Sulu/Sitemap/ContentSitemapProvider.php +++ b/Content/Infrastructure/Sulu/Sitemap/ContentSitemapProvider.php @@ -163,7 +163,7 @@ public function getMaxPage($scheme, $host): int { $queryBuilder = $this->createRoutesQueryBuilder(); try { - $amount = (int) $queryBuilder + $amount = $queryBuilder ->select('COUNT(' . self::ROUTE_ALIAS . ')') ->getQuery() ->getSingleScalarResult(); diff --git a/Content/Infrastructure/Sulu/Teaser/ContentTeaserProvider.php b/Content/Infrastructure/Sulu/Teaser/ContentTeaserProvider.php index bee1a301..bb1358a6 100644 --- a/Content/Infrastructure/Sulu/Teaser/ContentTeaserProvider.php +++ b/Content/Infrastructure/Sulu/Teaser/ContentTeaserProvider.php @@ -162,7 +162,7 @@ protected function createTeaser(DimensionContentInterface $dimensionContent, arr /** * @param B $dimensionContent - * @param array $data + * @param mixed[] $data */ protected function getTitle(DimensionContentInterface $dimensionContent, array $data): ?string { @@ -172,9 +172,7 @@ protected function getTitle(DimensionContentInterface $dimensionContent, array $ } } - $title = $data['title'] ?? $data['name'] ?? null; - - return \is_string($title) ? $title : null; + return $data['title'] ?? $data['name'] ?? null; } /** diff --git a/Resources/config/services.xml b/Resources/config/services.xml index 581d5f0e..4c0cc91b 100644 --- a/Resources/config/services.xml +++ b/Resources/config/services.xml @@ -163,6 +163,7 @@ + diff --git a/Tests/Application/ExampleTestBundle/Controller/ExampleController.php b/Tests/Application/ExampleTestBundle/Controller/ExampleController.php index becf9a08..4420c57a 100644 --- a/Tests/Application/ExampleTestBundle/Controller/ExampleController.php +++ b/Tests/Application/ExampleTestBundle/Controller/ExampleController.php @@ -97,8 +97,10 @@ public function cgetAction(Request $request): Response $fieldDescriptors = $this->fieldDescriptorFactory->getFieldDescriptors(Example::RESOURCE_KEY); /** @var DoctrineListBuilder $listBuilder */ $listBuilder = $this->listBuilderFactory->create(Example::class); + $listBuilder->where($fieldDescriptors['version'], (string) DimensionContentInterface::DEFAULT_VERSION); $listBuilder->addSelectField($fieldDescriptors['locale']); $listBuilder->addSelectField($fieldDescriptors['ghostLocale']); + $listBuilder->addSelectField($fieldDescriptors['version']); $listBuilder->setParameter('locale', $request->query->get('locale')); $this->restHelper->initializeListBuilder($listBuilder, $fieldDescriptors); diff --git a/Tests/Application/ExampleTestBundle/Entity/ExampleDimensionContent.php b/Tests/Application/ExampleTestBundle/Entity/ExampleDimensionContent.php index 7c84ed7a..b2438341 100644 --- a/Tests/Application/ExampleTestBundle/Entity/ExampleDimensionContent.php +++ b/Tests/Application/ExampleTestBundle/Entity/ExampleDimensionContent.php @@ -85,13 +85,10 @@ public function getTitle(): ?string return $this->title; } - /** - * @param array $templateData - */ public function setTemplateData(array $templateData): void { if (\array_key_exists('title', $templateData)) { - $this->title = \is_string($templateData['title']) ? $templateData['title'] : null; + $this->title = $templateData['title']; } $this->parentSetTemplateData($templateData); diff --git a/Tests/Application/ExampleTestBundle/Repository/ExampleRepository.php b/Tests/Application/ExampleTestBundle/Repository/ExampleRepository.php index 220c1151..1ec3f853 100644 --- a/Tests/Application/ExampleTestBundle/Repository/ExampleRepository.php +++ b/Tests/Application/ExampleTestBundle/Repository/ExampleRepository.php @@ -185,7 +185,7 @@ public function countBy(array $filters = []): int $queryBuilder->select('COUNT(DISTINCT example.id)'); - return (int) $queryBuilder->getQuery()->getSingleScalarResult(); + return (int) $queryBuilder->getQuery()->getSingleScalarResult(); // @phpstan-ignore-line } /** diff --git a/Tests/Application/ExampleTestBundle/Resources/config/lists/examples.xml b/Tests/Application/ExampleTestBundle/Resources/config/lists/examples.xml index bccb5fd3..97c1e3bc 100644 --- a/Tests/Application/ExampleTestBundle/Resources/config/lists/examples.xml +++ b/Tests/Application/ExampleTestBundle/Resources/config/lists/examples.xml @@ -66,5 +66,12 @@ + + + version + dimensionContent + + + diff --git a/Tests/Application/Kernel.php b/Tests/Application/Kernel.php index bd6d10c9..f58f486e 100644 --- a/Tests/Application/Kernel.php +++ b/Tests/Application/Kernel.php @@ -43,7 +43,7 @@ public function registerBundles(): iterable return $bundles; } - public function registerContainerConfiguration(LoaderInterface $loader): void + public function registerContainerConfiguration(LoaderInterface $loader) { parent::registerContainerConfiguration($loader); $loader->load(__DIR__ . '/config/config_' . $this->getContext() . '.yml'); diff --git a/Tests/Functional/Content/Infrastructure/Sulu/Sitemap/ContentSitemapProviderTest.php b/Tests/Functional/Content/Infrastructure/Sulu/Sitemap/ContentSitemapProviderTest.php index 5b1a72a0..bc2b4aea 100644 --- a/Tests/Functional/Content/Infrastructure/Sulu/Sitemap/ContentSitemapProviderTest.php +++ b/Tests/Functional/Content/Infrastructure/Sulu/Sitemap/ContentSitemapProviderTest.php @@ -167,7 +167,7 @@ public function testGetAlias(): void /** * @param SitemapUrl[] $sitemapEntries * - * @return array + * @return array */ private function mapSitemapEntries(array $sitemapEntries): array { diff --git a/Tests/Functional/Content/Infrastructure/Sulu/SmartContent/ContentDataProviderTest.php b/Tests/Functional/Content/Infrastructure/Sulu/SmartContent/ContentDataProviderTest.php index 1077a02f..d0cdf624 100644 --- a/Tests/Functional/Content/Infrastructure/Sulu/SmartContent/ContentDataProviderTest.php +++ b/Tests/Functional/Content/Infrastructure/Sulu/SmartContent/ContentDataProviderTest.php @@ -314,7 +314,7 @@ public function testResolveDataItems(): void /** @var int $expectedCount */ /** @var bool $expectedHasNextPage */ $dataProviderResult = $this->contentDataProvider->resolveDataItems( - $filters, // @phpstan-ignore-line + $filters, [], [ 'locale' => $locale, diff --git a/Tests/Unit/Content/Application/ContentDataMapper/DataMapper/WebspaceDataMapperTest.php b/Tests/Unit/Content/Application/ContentDataMapper/DataMapper/WebspaceDataMapperTest.php index f1ec5f11..2d33b8a2 100644 --- a/Tests/Unit/Content/Application/ContentDataMapper/DataMapper/WebspaceDataMapperTest.php +++ b/Tests/Unit/Content/Application/ContentDataMapper/DataMapper/WebspaceDataMapperTest.php @@ -90,7 +90,7 @@ public function testMapDefaultWebspace(): void $webspace = new Webspace(); $webspace->setKey('default-webspace'); - $this->webspaceCollection->setWebspaces(['default-webspace' => $webspace]); + $this->webspaceCollection->setWebspaces([$webspace]); $authorMapper = $this->createWebspaceDataMapperInstance(); $authorMapper->map($unlocalizedDimensionContent, $localizedDimensionContent, $data); diff --git a/Tests/Unit/Content/Infrastructure/Sulu/Page/Select/WebspaceSelectTest.php b/Tests/Unit/Content/Infrastructure/Sulu/Page/Select/WebspaceSelectTest.php index 6bff0831..29a4b6af 100644 --- a/Tests/Unit/Content/Infrastructure/Sulu/Page/Select/WebspaceSelectTest.php +++ b/Tests/Unit/Content/Infrastructure/Sulu/Page/Select/WebspaceSelectTest.php @@ -49,8 +49,8 @@ public function testGetValues(): void $webspaceB->setKey('webspace-b'); $webspaceB->setName('Webspace B'); $webspaceCollection = new WebspaceCollection([ - 'webspace-a' => $webspaceA, - 'webspace-b' => $webspaceB, + $webspaceA, + $webspaceB, ]); $this->webspaceManager->getWebspaceCollection() diff --git a/composer.json b/composer.json index e1ee0eb5..afed83e3 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ "doctrine/inflector": "^1.4.1 || ^2.0.1", "doctrine/collections": "^1.0", "doctrine/orm": "^2.5.3", - "doctrine/persistence": "^1.3 || ^2.0 || ^3.0", + "doctrine/persistence": "^1.3 || ^2.0", "doctrine/doctrine-bundle": "^1.10 || ^2.0", "friendsofsymfony/rest-bundle": "^2.6 || ^3.0", "massive/search-bundle": "^2.4", diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon new file mode 100644 index 00000000..ea83dcf9 --- /dev/null +++ b/phpstan-baseline.neon @@ -0,0 +1,22 @@ +parameters: + ignoreErrors: + - + message: "#^Parameter \\#1 \\$array of function array_values expects array, array\\\\|null given\\.$#" + count: 1 + path: Tests/Application/ExampleTestBundle/Entity/ExampleDimensionContent.php + + - + message: "#^Parameter \\#1 \\$array of function array_values expects array, array\\\\|null given\\.$#" + count: 2 + path: Tests/Unit/Content/Application/ContentNormalizer/ContentNormalizerTest.php + + - + message: "#^Parameter \\#1 \\$array of function array_values expects array, array\\\\|null given\\.$#" + count: 1 + path: Tests/Unit/Content/Domain/Model/DimensionContentTraitTest.php + + - + message: "#^Parameter \\#1 \\$array of function array_values expects array, array\\\\|null given\\.$#" + count: 3 + path: Tests/Unit/Content/Infrastructure/Sulu/Admin/ContentViewBuilderFactoryTest.php + From ef04a0a100d5396427bea06d6690c058022594c7 Mon Sep 17 00:00:00 2001 From: Redjan Ymeraj Date: Thu, 16 May 2024 15:02:59 +0200 Subject: [PATCH 2/2] List only version 0 of every content --- .../ExampleTestBundle/Controller/ExampleController.php | 1 - .../ExampleTestBundle/Resources/config/lists/examples.xml | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Tests/Application/ExampleTestBundle/Controller/ExampleController.php b/Tests/Application/ExampleTestBundle/Controller/ExampleController.php index 4420c57a..0081b930 100644 --- a/Tests/Application/ExampleTestBundle/Controller/ExampleController.php +++ b/Tests/Application/ExampleTestBundle/Controller/ExampleController.php @@ -97,7 +97,6 @@ public function cgetAction(Request $request): Response $fieldDescriptors = $this->fieldDescriptorFactory->getFieldDescriptors(Example::RESOURCE_KEY); /** @var DoctrineListBuilder $listBuilder */ $listBuilder = $this->listBuilderFactory->create(Example::class); - $listBuilder->where($fieldDescriptors['version'], (string) DimensionContentInterface::DEFAULT_VERSION); $listBuilder->addSelectField($fieldDescriptors['locale']); $listBuilder->addSelectField($fieldDescriptors['ghostLocale']); $listBuilder->addSelectField($fieldDescriptors['version']); diff --git a/Tests/Application/ExampleTestBundle/Resources/config/lists/examples.xml b/Tests/Application/ExampleTestBundle/Resources/config/lists/examples.xml index 97c1e3bc..b824d24e 100644 --- a/Tests/Application/ExampleTestBundle/Resources/config/lists/examples.xml +++ b/Tests/Application/ExampleTestBundle/Resources/config/lists/examples.xml @@ -7,7 +7,7 @@ dimensionContent Sulu\Bundle\ContentBundle\Tests\Application\ExampleTestBundle\Entity\Example.dimensionContents LEFT - dimensionContent.locale = :locale AND dimensionContent.stage = 'draft' + dimensionContent.locale = :locale AND dimensionContent.stage = 'draft' AND dimensionContent.version = '0' @@ -16,7 +16,7 @@ unlocalizedDimensionContent Sulu\Bundle\ContentBundle\Tests\Application\ExampleTestBundle\Entity\Example.dimensionContents LEFT - unlocalizedDimensionContent.locale IS NULL AND unlocalizedDimensionContent.stage = 'draft' + unlocalizedDimensionContent.locale IS NULL AND unlocalizedDimensionContent.stage = 'draft' AND unlocalizedDimensionContent.version = '0' @@ -25,7 +25,7 @@ ghostDimensionContent Sulu\Bundle\ContentBundle\Tests\Application\ExampleTestBundle\Entity\Example.dimensionContents LEFT - dimensionContent.locale IS NULL AND ghostDimensionContent.locale = unlocalizedDimensionContent.ghostLocale AND ghostDimensionContent.stage = 'draft' + dimensionContent.locale IS NULL AND ghostDimensionContent.locale = unlocalizedDimensionContent.ghostLocale AND ghostDimensionContent.stage = 'draft' AND ghostDimensionContent.version = '0'