Skip to content

Commit

Permalink
Merge branch '0.6' of github.com:sulu/SuluContentBundle into 0.x
Browse files Browse the repository at this point in the history
 Conflicts:
	.github/workflows/test-application.yaml
	Content/Application/ContentDataMapper/ContentDataMapperInterface.php
	Content/Application/ContentDataMapper/DataMapper/DataMapperInterface.php
	Content/Application/ContentDataMapper/DataMapper/ExcerptDataMapper.php
	Content/Application/ContentDataMapper/DataMapper/RoutableDataMapper.php
	Content/Application/ContentDataMapper/DataMapper/TemplateDataMapper.php
	Content/Application/DimensionContentCollectionFactory/DimensionContentCollectionFactory.php
	Content/Domain/Model/DimensionContentCollection.php
	Content/Infrastructure/Doctrine/DimensionContentRepository.php
	Content/Infrastructure/Sulu/SmartContent/Repository/ContentDataProviderRepository.php
	Content/Infrastructure/Sulu/Teaser/ContentTeaserProvider.php
	Tests/Application/ExampleTestBundle/Entity/ExampleDimensionContent.php
	Tests/Functional/Integration/ExampleControllerTest.php
	Tests/Unit/Content/Application/ContentDataMapper/DataMapper/ExcerptDataMapperTest.php
	Tests/Unit/Content/Application/ContentDataMapper/DataMapper/RoutableDataMapperTest.php
	Tests/Unit/Content/Application/ContentDataMapper/DataMapper/TemplateDataMapperTest.php
	Tests/Unit/Content/Infrastructure/Sulu/Admin/ContentViewBuilderFactoryTest.php
	Tests/Unit/Content/Infrastructure/Sulu/Preview/ContentObjectProviderTest.php
	composer.json
  • Loading branch information
alexander-schranz committed Mar 20, 2023
2 parents f4dfae2 + 8fddedc commit 69eee59
Show file tree
Hide file tree
Showing 138 changed files with 1,341 additions and 708 deletions.
11 changes: 9 additions & 2 deletions .github/workflows/test-application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ jobs:
fail-fast: false
matrix:
include:
- php-version: '7.2'
- php-version: '7.3'
coverage: false
dependency-versions: 'lowest'
env:
SYMFONY_DEPRECATIONS_HELPER: disabled

- php-version: '7.4'
coverage: true
coverage: false
dependency-versions: 'highest'
env:
SYMFONY_DEPRECATIONS_HELPER: weak
Expand All @@ -40,6 +40,12 @@ jobs:
SYMFONY_DEPRECATIONS_HELPER: weak

- php-version: '8.1'
coverage: true
dependency-versions: 'highest'
env:
SYMFONY_DEPRECATIONS_HELPER: weak

- php-version: '8.2'
coverage: false
dependency-versions: 'highest'
env:
Expand All @@ -64,6 +70,7 @@ jobs:
php-version: ${{ matrix.php-version }}
extensions: ctype, iconv, mysql
coverage: pcov
tools: 'composer:v2'

- name: Install composer dependencies
uses: ramsey/composer-install@v2
Expand Down
18 changes: 18 additions & 0 deletions Content/Application/ContentCopier/ContentCopierInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,14 @@
interface ContentCopierInterface
{
/**
* @template T of DimensionContentInterface
*
* @param ContentRichEntityInterface<T> $sourceContentRichEntity
* @param mixed[] $sourceDimensionAttributes
* @param ContentRichEntityInterface<T> $targetContentRichEntity
* @param mixed[] $targetDimensionAttributes
*
* @return T
*/
public function copy(
ContentRichEntityInterface $sourceContentRichEntity,
Expand All @@ -31,7 +37,13 @@ public function copy(
): DimensionContentInterface;

/**
* @template T of DimensionContentInterface
*
* @param DimensionContentCollectionInterface<T> $dimensionContentCollection
* @param ContentRichEntityInterface<T> $targetContentRichEntity
* @param mixed[] $targetDimensionAttributes
*
* @return T
*/
public function copyFromDimensionContentCollection(
DimensionContentCollectionInterface $dimensionContentCollection,
Expand All @@ -40,7 +52,13 @@ public function copyFromDimensionContentCollection(
): DimensionContentInterface;

/**
* @template T of DimensionContentInterface
*
* @param T $dimensionContent
* @param ContentRichEntityInterface<T> $targetContentRichEntity
* @param mixed[] $targetDimensionAttributes
*
* @return T
*/
public function copyFromDimensionContent(
DimensionContentInterface $dimensionContent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,16 @@
namespace Sulu\Bundle\ContentBundle\Content\Application\ContentDataMapper;

use Sulu\Bundle\ContentBundle\Content\Domain\Model\DimensionContentCollectionInterface;
use Sulu\Bundle\ContentBundle\Content\Domain\Model\DimensionContentInterface;

interface ContentDataMapperInterface
{
/**
* @param array<string, mixed> $data
* @template T of DimensionContentInterface
*
* @param DimensionContentCollectionInterface<T> $dimensionContentCollection
* @param mixed[] $dimensionAttributes
* @param array<string, mixed> $data
*/
public function map(
DimensionContentCollectionInterface $dimensionContentCollection,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
interface DataMapperInterface
{
/**
* @template T of DimensionContentInterface
*
* @param T $unlocalizedDimensionContent
* @param T $localizedDimensionContent
* @param array<string, mixed> $data
*/
public function map(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,11 @@ public function map(
throw new \RuntimeException(\sprintf('No route mapping found for "%s".', $resourceKey));
}

$routePath = $data[$name] ?? null;
/** @var string $routePath */
$routePath = $data[$name] ?? '';

if (!$routePath) {
/** @var mixed $routeGenerationData */
/** @var mixed[] $routeGenerationData */
$routeGenerationData = \array_merge(
$data,
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function map(
*/
private function setSeoData(SeoInterface $dimensionContent, array $data): void
{
$dimensionContent->setSeoTitle($data['seoTitle'] ?? null);
$dimensionContent->setSeoTitle($data['seoTitle'] ?? null); // @phpstan-ignore-line TODO where validate this?
$dimensionContent->setSeoDescription($data['seoDescription'] ?? null);
$dimensionContent->setSeoKeywords($data['seoKeywords'] ?? null);
$dimensionContent->setSeoCanonicalUrl($data['seoCanonicalUrl'] ?? null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ public function map(
}

/**
* @param WorkflowInterface&DimensionContentInterface $object
* @template T of DimensionContentInterface
*
* @param WorkflowInterface&T $object
* @param mixed[] $data
*/
private function setWorkflowData(WorkflowInterface $object, array $data): void
Expand All @@ -41,7 +43,9 @@ private function setWorkflowData(WorkflowInterface $object, array $data): void
}

/**
* @param WorkflowInterface&DimensionContentInterface $object
* @template T of DimensionContentInterface
*
* @param WorkflowInterface&T $object
* @param mixed[] $data
*/
private function setInitialPlaceToDraftDimension(WorkflowInterface $object, array $data): void
Expand All @@ -61,7 +65,9 @@ private function setInitialPlaceToDraftDimension(WorkflowInterface $object, arra
}

/**
* @param WorkflowInterface&DimensionContentInterface $object
* @template T of DimensionContentInterface
*
* @param WorkflowInterface&T $object
* @param mixed[] $data
*/
private function setPublishedToLiveDimension(WorkflowInterface $object, array $data): void
Expand All @@ -73,6 +79,7 @@ private function setPublishedToLiveDimension(WorkflowInterface $object, array $d
return;
}

/** @var string|null $published */
$published = $data['published'] ?? null;

if (!$published) {
Expand Down
5 changes: 5 additions & 0 deletions Content/Application/ContentIndexer/ContentIndexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,12 @@ public function deindexDimensionContent(DimensionContentInterface $dimensionCont
}

/**
* @template T of DimensionContentInterface
*
* @param ContentRichEntityInterface<T> $contentRichEntity
* @param mixed[] $dimensionAttributes
*
* @return T
*/
private function loadDimensionContent(
ContentRichEntityInterface $contentRichEntity,
Expand Down
17 changes: 16 additions & 1 deletion Content/Application/ContentIndexer/ContentIndexerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,32 @@
interface ContentIndexerInterface
{
/**
* @template T of DimensionContentInterface
*
* @param ContentRichEntityInterface<T> $contentRichEntity
* @param mixed[] $dimensionAttributes
*
* @return T
*/
public function index(ContentRichEntityInterface $contentRichEntity, array $dimensionAttributes): DimensionContentInterface;

/**
* @template T of DimensionContentInterface
*
* @param T $dimensionContent
*/
public function indexDimensionContent(DimensionContentInterface $dimensionContent): void;

/**
* @param mixed $id
* @param int|string $id
* @param mixed[] $dimensionAttributes
*/
public function deindex(string $resourceKey, $id, array $dimensionAttributes = []): void;

/**
* @template T of DimensionContentInterface
*
* @param T $dimensionContent
*/
public function deindexDimensionContent(DimensionContentInterface $dimensionContent): void;
}
32 changes: 31 additions & 1 deletion Content/Application/ContentManager/ContentManagerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,44 @@
interface ContentManagerInterface
{
/**
* @template T of DimensionContentInterface
*
* @param ContentRichEntityInterface<T> $contentRichEntity
* @param mixed[] $dimensionAttributes
*
* @return T
*/
public function resolve(ContentRichEntityInterface $contentRichEntity, array $dimensionAttributes): DimensionContentInterface;

/**
* @template T of DimensionContentInterface
*
* @param ContentRichEntityInterface<T> $contentRichEntity
* @param mixed[] $data
* @param mixed[] $dimensionAttributes
*
* @return T
*/
public function persist(ContentRichEntityInterface $contentRichEntity, array $data, array $dimensionAttributes): DimensionContentInterface;

/**
* @template T of DimensionContentInterface
*
* @param T $dimensionContent
*
* @return mixed[]
*/
public function normalize(DimensionContentInterface $dimensionContent): array;

/**
* @template T of DimensionContentInterface
*
* @param ContentRichEntityInterface<T> $sourceContentRichEntity
* @param mixed[] $sourceDimensionAttributes
* @param ContentRichEntityInterface<T> $targetContentRichEntity
* @param mixed[] $targetDimensionAttributes
*
* @return T
*/
public function copy(
ContentRichEntityInterface $sourceContentRichEntity,
Expand All @@ -46,7 +66,12 @@ public function copy(
): DimensionContentInterface;

/**
* @template T of DimensionContentInterface
*
* @param ContentRichEntityInterface<T> $contentRichEntity
* @param mixed[] $dimensionAttributes
*
* @return T
*/
public function applyTransition(
ContentRichEntityInterface $contentRichEntity,
Expand All @@ -55,12 +80,17 @@ public function applyTransition(
): DimensionContentInterface;

/**
* @template T of DimensionContentInterface
*
* @param ContentRichEntityInterface<T> $contentRichEntity
* @param mixed[] $dimensionAttributes
*
* @return T
*/
public function index(ContentRichEntityInterface $contentRichEntity, array $dimensionAttributes): DimensionContentInterface;

/**
* @param mixed $id
* @param int|string $id
* @param mixed[] $dimensionAttributes
*/
public function deindex(string $resourceKey, $id, array $dimensionAttributes = []): void;
Expand Down
7 changes: 7 additions & 0 deletions Content/Application/ContentMerger/ContentMergerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,12 @@

interface ContentMergerInterface
{
/**
* @template T of DimensionContentInterface
*
* @param DimensionContentCollectionInterface<T> $dimensionContentCollection
*
* @return T
*/
public function merge(DimensionContentCollectionInterface $dimensionContentCollection): DimensionContentInterface;
}
4 changes: 2 additions & 2 deletions Content/Application/ContentMerger/Merger/ExcerptMerger.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ public function merge(object $targetObject, object $sourceObject): void
}

if ($excerptTags = $sourceObject->getExcerptTags()) {
if (!empty($excerptTags)) {
if (\count($excerptTags) > 0) { // @phpstan-ignore-line false positive for phpstan thinks it is a non-empty-array
$targetObject->setExcerptTags($excerptTags);
}
}

if ($excerptCategories = $sourceObject->getExcerptCategories()) {
if (!empty($excerptCategories)) {
if (\count($excerptCategories) > 0) { // @phpstan-ignore-line false positive for phpstan thinks it is a non-empty-array
$targetObject->setExcerptCategories($excerptCategories);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

use Doctrine\Common\Util\ClassUtils;
use Doctrine\ORM\EntityManagerInterface;
use Sulu\Bundle\ContentBundle\Content\Domain\Model\ContentRichEntityInterface;
use Sulu\Bundle\ContentBundle\Content\Domain\Model\DimensionContentInterface;

class ContentMetadataInspector implements ContentMetadataInspectorInterface
Expand All @@ -29,12 +30,19 @@ public function __construct(EntityManagerInterface $entityManager)
$this->entityManager = $entityManager;
}

/**
* @template T of DimensionContentInterface
*
* @param class-string<ContentRichEntityInterface<T>> $contentRichEntityClass
*
* @return class-string<T>
*/
public function getDimensionContentClass(string $contentRichEntityClass): string
{
$contentRichEntityClass = ClassUtils::getRealClass($contentRichEntityClass);

$classMetadata = $this->entityManager->getClassMetadata($contentRichEntityClass);
/** @var array{targetEntity: class-string<DimensionContentInterface>} $associationMapping */
/** @var array{targetEntity: class-string<T>} $associationMapping */
$associationMapping = $classMetadata->getAssociationMapping('dimensionContents');

return $associationMapping['targetEntity'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,18 @@
interface ContentMetadataInspectorInterface
{
/**
* @param class-string<ContentRichEntityInterface> $contentRichEntityClass
* @template T of DimensionContentInterface
*
* @return class-string<DimensionContentInterface>
* @param class-string<ContentRichEntityInterface<T>> $contentRichEntityClass
*
* @return class-string<T>
*/
public function getDimensionContentClass(string $contentRichEntityClass): string;

/**
* @param class-string<ContentRichEntityInterface> $contentRichEntityClass
* @template T of DimensionContentInterface
*
* @param class-string<ContentRichEntityInterface<T>> $contentRichEntityClass
*/
public function getDimensionContentPropertyName(string $contentRichEntityClass): string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function enhance(object $object, array $normalizedData): array
return $normalizedData;
}

$normalizedData = \array_merge($normalizedData['templateData'], $normalizedData);
$normalizedData = \array_merge($normalizedData['templateData'], $normalizedData); // @phpstan-ignore-line TODO check whats going on here
unset($normalizedData['templateData']);

$normalizedData['template'] = $normalizedData['templateKey'];
Expand Down
Loading

0 comments on commit 69eee59

Please sign in to comment.