Skip to content

Commit

Permalink
Rename ContentResolver to ContentProjectionNormalizer
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-schranz committed Dec 16, 2019
1 parent e598f32 commit 63cd466
Show file tree
Hide file tree
Showing 17 changed files with 76 additions and 94 deletions.
12 changes: 6 additions & 6 deletions Content/Application/ContentCopier/ContentCopier.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
namespace Sulu\Bundle\ContentBundle\Content\Application\ContentCopier;

use Sulu\Bundle\ContentBundle\Content\Application\ContentLoader\ContentLoaderInterface;
use Sulu\Bundle\ContentBundle\Content\Application\ContentNormalizer\ContentProjectionNormalizerInterface;
use Sulu\Bundle\ContentBundle\Content\Application\ContentPersister\ContentPersisterInterface;
use Sulu\Bundle\ContentBundle\Content\Application\ViewResolver\ApiViewResolverInterface;
use Sulu\Bundle\ContentBundle\Content\Domain\Factory\ContentProjectionFactoryInterface;
use Sulu\Bundle\ContentBundle\Content\Domain\Model\ContentProjectionInterface;
use Sulu\Bundle\ContentBundle\Content\Domain\Model\ContentRichEntityInterface;
Expand All @@ -39,20 +39,20 @@ class ContentCopier implements ContentCopierInterface
private $contentPersister;

/**
* @var ApiViewResolverInterface
* @var ContentProjectionNormalizerInterface
*/
private $contentResolver;
private $contentProjectionNormalizer;

public function __construct(
ContentLoaderInterface $contentLoader,
ContentProjectionFactoryInterface $viewFactory,
ContentPersisterInterface $contentPersister,
ApiViewResolverInterface $contentResolver
ContentProjectionNormalizerInterface $contentProjectionNormalizer
) {
$this->contentLoader = $contentLoader;
$this->viewFactory = $viewFactory;
$this->contentPersister = $contentPersister;
$this->contentResolver = $contentResolver;
$this->contentProjectionNormalizer = $contentProjectionNormalizer;
}

public function copy(
Expand Down Expand Up @@ -81,7 +81,7 @@ public function copyFromContentProjection(
ContentRichEntityInterface $targetContentRichENtity,
array $targetDimensionAttributes
): ContentProjectionInterface {
$data = $this->contentResolver->resolve($sourceContentProjection);
$data = $this->contentProjectionNormalizer->normalize($sourceContentProjection);

return $this->contentPersister->persist($targetContentRichENtity, $data, $targetDimensionAttributes);
}
Expand Down
14 changes: 7 additions & 7 deletions Content/Application/ContentFacade/ContentFacade.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@

use Sulu\Bundle\ContentBundle\Content\Application\ContentCopier\ContentCopierInterface;
use Sulu\Bundle\ContentBundle\Content\Application\ContentLoader\ContentLoaderInterface;
use Sulu\Bundle\ContentBundle\Content\Application\ContentNormalizer\ContentProjectionNormalizerInterface;
use Sulu\Bundle\ContentBundle\Content\Application\ContentPersister\ContentPersisterInterface;
use Sulu\Bundle\ContentBundle\Content\Application\ContentWorkflow\ContentWorkflowInterface;
use Sulu\Bundle\ContentBundle\Content\Application\ViewResolver\ApiViewResolverInterface;
use Sulu\Bundle\ContentBundle\Content\Domain\Model\ContentProjectionInterface;
use Sulu\Bundle\ContentBundle\Content\Domain\Model\ContentRichEntityInterface;

Expand All @@ -34,9 +34,9 @@ class ContentFacade implements ContentFacadeInterface
private $contentPersister;

/**
* @var ApiViewResolverInterface
* @var ContentProjectionNormalizerInterface
*/
private $contentResolver;
private $contentProjectionNormalizer;

/**
* @var ContentCopierInterface
Expand All @@ -51,13 +51,13 @@ class ContentFacade implements ContentFacadeInterface
public function __construct(
ContentLoaderInterface $contentLoader,
ContentPersisterInterface $contentPersister,
ApiViewResolverInterface $contentResolver,
ContentProjectionNormalizerInterface $contentProjectionNormalizer,
ContentCopierInterface $contentCopier,
ContentWorkflowInterface $contentWorkflow
) {
$this->contentLoader = $contentLoader;
$this->contentPersister = $contentPersister;
$this->contentResolver = $contentResolver;
$this->contentProjectionNormalizer = $contentProjectionNormalizer;
$this->contentCopier = $contentCopier;
$this->contentWorkflow = $contentWorkflow;
}
Expand All @@ -72,9 +72,9 @@ public function persist(ContentRichEntityInterface $contentRichEntity, array $da
return $this->contentPersister->persist($contentRichEntity, $data, $dimensionAttributes);
}

public function resolve(ContentProjectionInterface $contentProjection): array
public function normalize(ContentProjectionInterface $contentProjection): array
{
return $this->contentResolver->resolve($contentProjection);
return $this->contentProjectionNormalizer->normalize($contentProjection);
}

public function copy(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function persist(ContentRichEntityInterface $contentRichEntity, array $da
/**
* @return mixed[]
*/
public function resolve(ContentProjectionInterface $contentProjection): array;
public function normalize(ContentProjectionInterface $contentProjection): array;

/**
* @param mixed[] $sourceDimensionAttributes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@
* with this source code in the file LICENSE.
*/

namespace Sulu\Bundle\ContentBundle\Content\Application\ViewResolver;
namespace Sulu\Bundle\ContentBundle\Content\Application\ContentNormalizer;

use Sulu\Bundle\ContentBundle\Content\Application\ViewResolver\Resolver\ResolverInterface;
use Sulu\Bundle\ContentBundle\Content\Application\ContentNormalizer\Resolver\ResolverInterface;
use Sulu\Bundle\ContentBundle\Content\Domain\Model\ContentProjectionInterface;
use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer;
use Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
use Symfony\Component\Serializer\Serializer;

class ApiViewResolver implements ViewResolverInterface, ApiViewResolverInterface
class ContentProjectionNormalizer implements ContentProjectionNormalizerInterface
{
/**
* @var iterable<ResolverInterface>
Expand All @@ -43,7 +43,7 @@ public function __construct(
$this->serializer = $serializer ?: $this->createSerializer();
}

public function resolve(ContentProjectionInterface $contentProjection): array
public function normalize(ContentProjectionInterface $contentProjection): array
{
$ignoreAttributes = ['id'];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
* with this source code in the file LICENSE.
*/

namespace Sulu\Bundle\ContentBundle\Content\Application\ViewResolver;
namespace Sulu\Bundle\ContentBundle\Content\Application\ContentNormalizer;

use Sulu\Bundle\ContentBundle\Content\Domain\Model\ContentProjectionInterface;

interface ViewResolverInterface
interface ContentProjectionNormalizerInterface
{
/**
* @return mixed[]
*/
public function resolve(ContentProjectionInterface $contentProjection): array;
public function normalize(ContentProjectionInterface $contentProjection): array;
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* with this source code in the file LICENSE.
*/

namespace Sulu\Bundle\ContentBundle\Content\Application\ViewResolver\Resolver;
namespace Sulu\Bundle\ContentBundle\Content\Application\ContentNormalizer\Resolver;

use Sulu\Bundle\ContentBundle\Content\Domain\Model\ExcerptInterface;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* with this source code in the file LICENSE.
*/

namespace Sulu\Bundle\ContentBundle\Content\Application\ViewResolver\Resolver;
namespace Sulu\Bundle\ContentBundle\Content\Application\ContentNormalizer\Resolver;

interface ResolverInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* with this source code in the file LICENSE.
*/

namespace Sulu\Bundle\ContentBundle\Content\Application\ViewResolver\Resolver;
namespace Sulu\Bundle\ContentBundle\Content\Application\ContentNormalizer\Resolver;

use Sulu\Bundle\ContentBundle\Content\Domain\Model\TemplateInterface;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* with this source code in the file LICENSE.
*/

namespace Sulu\Bundle\ContentBundle\Content\Application\ViewResolver\Resolver;
namespace Sulu\Bundle\ContentBundle\Content\Application\ContentNormalizer\Resolver;

use Sulu\Bundle\ContentBundle\Content\Domain\Model\WorkflowInterface;

Expand Down
18 changes: 0 additions & 18 deletions Content/Application/ViewResolver/ApiViewResolverInterface.php

This file was deleted.

12 changes: 6 additions & 6 deletions Resources/config/resolver.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<!-- Resolver -->
<service id="sulu_content.excerpt_resolver" class="Sulu\Bundle\ContentBundle\Content\Application\ViewResolver\Resolver\ExcerptResolver">
<tag name="sulu_content.api_resolver"/>
<service id="sulu_content.excerpt_resolver" class="Sulu\Bundle\ContentBundle\Content\Application\ContentNormalizer\Resolver\ExcerptResolver">
<tag name="sulu_content.resolver"/>
</service>

<service id="sulu_content.seo_resolver" class="Sulu\Bundle\ContentBundle\Content\Application\ViewResolver\Resolver\TemplateResolver">
<tag name="sulu_content.api_resolver"/>
<service id="sulu_content.seo_resolver" class="Sulu\Bundle\ContentBundle\Content\Application\ContentNormalizer\Resolver\TemplateResolver">
<tag name="sulu_content.resolver"/>
</service>

<service id="sulu_content.workflow_resolver" class="Sulu\Bundle\ContentBundle\Content\Application\ViewResolver\Resolver\WorkflowResolver">
<tag name="sulu_content.api_resolver"/>
<service id="sulu_content.workflow_resolver" class="Sulu\Bundle\ContentBundle\Content\Application\ContentNormalizer\Resolver\WorkflowResolver">
<tag name="sulu_content.resolver"/>
</service>
</services>
</container>
12 changes: 6 additions & 6 deletions Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,19 @@

<service id="Sulu\Bundle\ContentBundle\Content\Application\ContentLoader\ContentLoaderInterface" alias="sulu_content.content_loader"/>

<!-- ApiViewResolver -->
<service id="sulu_content.api_view_resolver" class="Sulu\Bundle\ContentBundle\Content\Application\ViewResolver\ApiViewResolver">
<argument type="tagged" tag="sulu_content.api_resolver"/>
<!-- ContentProjectionNormalizer -->
<service id="sulu_content.content_projection_normalizer" class="Sulu\Bundle\ContentBundle\Content\Application\ContentNormalizer\ContentProjectionNormalizer">
<argument type="tagged" tag="sulu_content.resolver"/>
</service>

<service id="Sulu\Bundle\ContentBundle\Content\Application\ViewResolver\ApiViewResolverInterface" alias="sulu_content.api_view_resolver"/>
<service id="Sulu\Bundle\ContentBundle\Content\Application\ContentNormalizer\ContentProjectionNormalizerInterface" alias="sulu_content.content_projection_normalizer"/>

<!-- Content Copier -->
<service id="sulu_content.content_copier" class="Sulu\Bundle\ContentBundle\Content\Application\ContentCopier\ContentCopier">
<argument type="service" id="sulu_content.content_loader"/>
<argument type="service" id="sulu_content.content_projection_factory"/>
<argument type="service" id="sulu_content.content_persister"/>
<argument type="service" id="sulu_content.api_view_resolver"/>
<argument type="service" id="sulu_content.content_projection_normalizer"/>
</service>

<service id="Sulu\Bundle\ContentBundle\Content\Application\ContentCopier\ContentCopierInterface" alias="sulu_content.content_copier"/>
Expand All @@ -120,7 +120,7 @@
<service id="sulu_content.content_facade" class="Sulu\Bundle\ContentBundle\Content\Application\ContentFacade\ContentFacade">
<argument type="service" id="sulu_content.content_loader"/>
<argument type="service" id="sulu_content.content_persister"/>
<argument type="service" id="sulu_content.api_view_resolver"/>
<argument type="service" id="sulu_content.content_projection_normalizer"/>
<argument type="service" id="sulu_content.content_copier"/>
<argument type="service" id="sulu_content.content_workflow"/>
</service>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ protected function getData(Request $request): array
*/
protected function resolve(Example $example, ContentProjectionInterface $contentProjection): array
{
$resolvedData = $this->contentFacade->resolve($contentProjection);
$resolvedData = $this->contentFacade->normalize($contentProjection);

// If used autoincrement ids the id need to be set here on
// the resolvedData else on create no id will be returned
Expand Down
24 changes: 12 additions & 12 deletions Tests/Unit/Content/Application/ContentCopier/ContentCopierTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
use Sulu\Bundle\ContentBundle\Content\Application\ContentCopier\ContentCopier;
use Sulu\Bundle\ContentBundle\Content\Application\ContentCopier\ContentCopierInterface;
use Sulu\Bundle\ContentBundle\Content\Application\ContentLoader\ContentLoaderInterface;
use Sulu\Bundle\ContentBundle\Content\Application\ContentNormalizer\ContentProjectionNormalizerInterface;
use Sulu\Bundle\ContentBundle\Content\Application\ContentPersister\ContentPersisterInterface;
use Sulu\Bundle\ContentBundle\Content\Application\ViewResolver\ApiViewResolverInterface;
use Sulu\Bundle\ContentBundle\Content\Domain\Factory\ContentProjectionFactoryInterface;
use Sulu\Bundle\ContentBundle\Content\Domain\Model\ContentProjectionInterface;
use Sulu\Bundle\ContentBundle\Content\Domain\Model\ContentRichEntityInterface;
Expand All @@ -30,13 +30,13 @@ protected function createContentCopierInstance(
ContentLoaderInterface $contentLoader,
ContentProjectionFactoryInterface $viewFactory,
ContentPersisterInterface $contentPersister,
ApiViewResolverInterface $contentResolver
ContentProjectionNormalizerInterface $contentProjectionNormalizer
): ContentCopierInterface {
return new ContentCopier(
$contentLoader,
$viewFactory,
$contentPersister,
$contentResolver
$contentProjectionNormalizer
);
}

Expand All @@ -53,13 +53,13 @@ public function testCopy(): void
$contentLoader = $this->prophesize(ContentLoaderInterface::class);
$contentProjectionFactory = $this->prophesize(ContentProjectionFactoryInterface::class);
$contentPersister = $this->prophesize(ContentPersisterInterface::class);
$contentResolver = $this->prophesize(ApiViewResolverInterface::class);
$contentProjectionNormalizer = $this->prophesize(ContentProjectionNormalizerInterface::class);

$contentLoader->load($sourceContentRichEntity->reveal(), $sourceDimensionAttributes)
->willReturn($sourceContentProjection->reveal())
->shouldBeCalled();

$contentResolver->resolve($sourceContentProjection->reveal())
$contentProjectionNormalizer->normalize($sourceContentProjection->reveal())
->willReturn(['resolved' => 'data'])
->shouldBeCalled();

Expand All @@ -71,7 +71,7 @@ public function testCopy(): void
$contentLoader->reveal(),
$contentProjectionFactory->reveal(),
$contentPersister->reveal(),
$contentResolver->reveal()
$contentProjectionNormalizer->reveal()
);

$this->assertSame(
Expand All @@ -97,13 +97,13 @@ public function testCopyFromDimensionContentCollection(): void
$contentLoader = $this->prophesize(ContentLoaderInterface::class);
$contentProjectionFactory = $this->prophesize(ContentProjectionFactoryInterface::class);
$contentPersister = $this->prophesize(ContentPersisterInterface::class);
$contentResolver = $this->prophesize(ApiViewResolverInterface::class);
$contentProjectionNormalizer = $this->prophesize(ContentProjectionNormalizerInterface::class);

$contentProjectionFactory->create($sourceContentDimensionCollection->reveal())
->willReturn($sourceContentProjection->reveal())
->shouldBeCalled();

$contentResolver->resolve($sourceContentProjection->reveal())
$contentProjectionNormalizer->normalize($sourceContentProjection->reveal())
->willReturn(['resolved' => 'data'])
->shouldBeCalled();

Expand All @@ -115,7 +115,7 @@ public function testCopyFromDimensionContentCollection(): void
$contentLoader->reveal(),
$contentProjectionFactory->reveal(),
$contentPersister->reveal(),
$contentResolver->reveal()
$contentProjectionNormalizer->reveal()
);

$this->assertSame(
Expand All @@ -139,9 +139,9 @@ public function testCopyFromContentProjection(): void
$contentLoader = $this->prophesize(ContentLoaderInterface::class);
$contentProjectionFactory = $this->prophesize(ContentProjectionFactoryInterface::class);
$contentPersister = $this->prophesize(ContentPersisterInterface::class);
$contentResolver = $this->prophesize(ApiViewResolverInterface::class);
$contentProjectionNormalizer = $this->prophesize(ContentProjectionNormalizerInterface::class);

$contentResolver->resolve($sourceContentProjection->reveal())
$contentProjectionNormalizer->normalize($sourceContentProjection->reveal())
->willReturn(['resolved' => 'data'])
->shouldBeCalled();

Expand All @@ -153,7 +153,7 @@ public function testCopyFromContentProjection(): void
$contentLoader->reveal(),
$contentProjectionFactory->reveal(),
$contentPersister->reveal(),
$contentResolver->reveal()
$contentProjectionNormalizer->reveal()
);

$this->assertSame(
Expand Down
Loading

0 comments on commit 63cd466

Please sign in to comment.