Skip to content

Commit

Permalink
Rename ContentFacade to ContentManager (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-schranz authored and niklasnatter committed Dec 17, 2019
1 parent b2b0947 commit 66f4145
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 38 deletions.
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\ContentFacade;
namespace Sulu\Bundle\ContentBundle\Content\Application\ContentManager;

use Sulu\Bundle\ContentBundle\Content\Application\ContentCopier\ContentCopierInterface;
use Sulu\Bundle\ContentBundle\Content\Application\ContentPersister\ContentPersisterInterface;
Expand All @@ -21,7 +21,7 @@
use Sulu\Bundle\ContentBundle\Content\Domain\Model\ContentProjectionInterface;
use Sulu\Bundle\ContentBundle\Content\Domain\Model\ContentRichEntityInterface;

class ContentFacade implements ContentFacadeInterface
class ContentManager implements ContentManagerInterface
{
/**
* @var ContentResolverInterface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
* with this source code in the file LICENSE.
*/

namespace Sulu\Bundle\ContentBundle\Content\Application\ContentFacade;
namespace Sulu\Bundle\ContentBundle\Content\Application\ContentManager;

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

interface ContentFacadeInterface
interface ContentManagerInterface
{
/**
* @param mixed[] $dimensionAttributes
Expand Down
6 changes: 3 additions & 3 deletions Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,15 @@
<tag name="kernel.event_subscriber"/>
</service>

<!-- ContentFacade -->
<service id="sulu_content.content_facade" class="Sulu\Bundle\ContentBundle\Content\Application\ContentFacade\ContentFacade">
<!-- Content Manager -->
<service id="sulu_content.content_manager" class="Sulu\Bundle\ContentBundle\Content\Application\ContentManager\ContentManager">
<argument type="service" id="sulu_content.content_resolver"/>
<argument type="service" id="sulu_content.content_persister"/>
<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>

<service id="Sulu\Bundle\ContentBundle\Content\Application\ContentFacade\ContentFacadeInterface" alias="sulu_content.content_facade"/>
<service id="Sulu\Bundle\ContentBundle\Content\Application\ContentManager\ContentManagerInterface" alias="sulu_content.content_manager"/>
</services>
</container>
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use Doctrine\ORM\EntityManagerInterface;
use FOS\RestBundle\Routing\ClassResourceInterface;
use FOS\RestBundle\View\ViewHandlerInterface;
use Sulu\Bundle\ContentBundle\Content\Application\ContentFacade\ContentFacadeInterface;
use Sulu\Bundle\ContentBundle\Content\Application\ContentManager\ContentManagerInterface;
use Sulu\Bundle\ContentBundle\Content\Domain\Model\ContentProjectionInterface;
use Sulu\Bundle\ContentBundle\Content\Domain\Model\WorkflowInterface;
use Sulu\Bundle\ContentBundle\Tests\Application\ExampleTestBundle\Entity\Example;
Expand Down Expand Up @@ -50,9 +50,9 @@ class ExampleController extends AbstractRestController implements ClassResourceI
private $restHelper;

/**
* @var ContentFacadeInterface
* @var ContentManagerInterface
*/
private $contentFacade;
private $contentManager;

/**
* @var EntityManagerInterface
Expand All @@ -65,13 +65,13 @@ public function __construct(
FieldDescriptorFactoryInterface $fieldDescriptorFactory,
DoctrineListBuilderFactoryInterface $listBuilderFactory,
RestHelperInterface $restHelper,
ContentFacadeInterface $contentFacade,
ContentManagerInterface $contentManager,
EntityManagerInterface $entityManager
) {
$this->fieldDescriptorFactory = $fieldDescriptorFactory;
$this->listBuilderFactory = $listBuilderFactory;
$this->restHelper = $restHelper;
$this->contentFacade = $contentFacade;
$this->contentManager = $contentManager;
$this->entityManager = $entityManager;

parent::__construct($viewHandler, $tokenStorage);
Expand Down Expand Up @@ -113,7 +113,7 @@ public function getAction(Request $request, int $id): Response
}

$dimensionAttributes = $this->getDimensionAttributes($request);
$contentProjection = $this->contentFacade->resolve($example, $dimensionAttributes);
$contentProjection = $this->contentManager->resolve($example, $dimensionAttributes);

return $this->handleView($this->view($this->resolve($example, $contentProjection)));
}
Expand All @@ -128,13 +128,13 @@ public function postAction(Request $request): Response
$data = $this->getData($request);
$dimensionAttributes = $this->getDimensionAttributes($request); // ["locale" => "en", "stage" => "draft"]

$contentProjection = $this->contentFacade->persist($example, $data, $dimensionAttributes);
$contentProjection = $this->contentManager->persist($example, $data, $dimensionAttributes);

$this->entityManager->persist($example);
$this->entityManager->flush();

if ('publish' === $request->query->get('action')) {
$contentProjection = $this->contentFacade->applyTransition(
$contentProjection = $this->contentManager->applyTransition(
$example,
$dimensionAttributes,
WorkflowInterface::WORKFLOW_TRANSITION_PUBLISH
Expand All @@ -161,12 +161,12 @@ public function putAction(Request $request, int $id): Response
$data = $this->getData($request);
$dimensionAttributes = $this->getDimensionAttributes($request); // ["locale" => "en", "stage" => "draft"]

$contentProjection = $this->contentFacade->persist($example, $data, $dimensionAttributes);
$contentProjection = $this->contentManager->persist($example, $data, $dimensionAttributes);

$this->entityManager->flush();

if ('publish' === $request->query->get('action')) {
$contentProjection = $this->contentFacade->applyTransition(
$contentProjection = $this->contentManager->applyTransition(
$example,
$dimensionAttributes,
WorkflowInterface::WORKFLOW_TRANSITION_PUBLISH
Expand Down Expand Up @@ -220,7 +220,7 @@ protected function getData(Request $request): array
*/
protected function resolve(Example $example, ContentProjectionInterface $contentProjection): array
{
$resolvedData = $this->contentFacade->normalize($contentProjection);
$resolvedData = $this->contentManager->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
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ services:
- '@sulu_core.list_builder.field_descriptor_factory'
- '@sulu_core.doctrine_list_builder_factory'
- '@sulu_core.doctrine_rest_helper'
- '@sulu_content.content_facade'
- '@sulu_content.content_manager'
- '@doctrine.orm.entity_manager'
tags:
- { name: sulu.context, context: admin }
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,29 @@
* with this source code in the file LICENSE.
*/

namespace Sulu\Bundle\ContentBundle\Tests\Unit\Content\Application\ContentFacade;
namespace Sulu\Bundle\ContentBundle\Tests\Unit\Content\Application\ContentManager;

use PHPUnit\Framework\TestCase;
use Sulu\Bundle\ContentBundle\Content\Application\ContentCopier\ContentCopierInterface;
use Sulu\Bundle\ContentBundle\Content\Application\ContentFacade\ContentFacade;
use Sulu\Bundle\ContentBundle\Content\Application\ContentFacade\ContentFacadeInterface;
use Sulu\Bundle\ContentBundle\Content\Application\ContentManager\ContentManager;
use Sulu\Bundle\ContentBundle\Content\Application\ContentManager\ContentManagerInterface;
use Sulu\Bundle\ContentBundle\Content\Application\ContentPersister\ContentPersisterInterface;
use Sulu\Bundle\ContentBundle\Content\Application\ContentProjectionNormalizer\ContentProjectionNormalizerInterface;
use Sulu\Bundle\ContentBundle\Content\Application\ContentResolver\ContentResolverInterface;
use Sulu\Bundle\ContentBundle\Content\Application\ContentWorkflow\ContentWorkflowInterface;
use Sulu\Bundle\ContentBundle\Content\Domain\Model\ContentProjectionInterface;
use Sulu\Bundle\ContentBundle\Content\Domain\Model\ContentRichEntityInterface;

class ContentFacadeTest extends TestCase
class ContentManagerTest extends TestCase
{
protected function createContentFacadeInstance(
protected function createContentManagerInstance(
ContentResolverInterface $contentResolver,
ContentPersisterInterface $contentPersister,
ContentProjectionNormalizerInterface $contentProjectionNormalizer,
ContentCopierInterface $contentCopier,
ContentWorkflowInterface $contentWorkflow
): ContentFacadeInterface {
return new ContentFacade($contentResolver, $contentPersister, $contentProjectionNormalizer, $contentCopier, $contentWorkflow);
): ContentManagerInterface {
return new ContentManager($contentResolver, $contentPersister, $contentProjectionNormalizer, $contentCopier, $contentWorkflow);
}

public function testLoad(): void
Expand All @@ -48,7 +48,7 @@ public function testLoad(): void
$contentCopier = $this->prophesize(ContentCopierInterface::class);
$contentWorkflow = $this->prophesize(ContentWorkflowInterface::class);

$contentFacade = $this->createContentFacadeInstance(
$contentManager = $this->createContentManagerInstance(
$contentResolver->reveal(),
$contentPersister->reveal(),
$contentProjectionNormalizer->reveal(),
Expand All @@ -62,7 +62,7 @@ public function testLoad(): void

$this->assertSame(
$contentProjection->reveal(),
$contentFacade->resolve($contentRichEntity->reveal(), $dimensionAttributes)
$contentManager->resolve($contentRichEntity->reveal(), $dimensionAttributes)
);
}

Expand All @@ -79,7 +79,7 @@ public function testPersist(): void
$contentCopier = $this->prophesize(ContentCopierInterface::class);
$contentWorkflow = $this->prophesize(ContentWorkflowInterface::class);

$contentFacade = $this->createContentFacadeInstance(
$contentManager = $this->createContentManagerInstance(
$contentResolver->reveal(),
$contentPersister->reveal(),
$contentProjectionNormalizer->reveal(),
Expand All @@ -93,7 +93,7 @@ public function testPersist(): void

$this->assertSame(
$contentProjection->reveal(),
$contentFacade->persist($contentRichEntity->reveal(), $data, $dimensionAttributes)
$contentManager->persist($contentRichEntity->reveal(), $data, $dimensionAttributes)
);
}

Expand All @@ -107,7 +107,7 @@ public function testResolve(): void
$contentCopier = $this->prophesize(ContentCopierInterface::class);
$contentWorkflow = $this->prophesize(ContentWorkflowInterface::class);

$contentFacade = $this->createContentFacadeInstance(
$contentManager = $this->createContentManagerInstance(
$contentResolver->reveal(),
$contentPersister->reveal(),
$contentProjectionNormalizer->reveal(),
Expand All @@ -121,7 +121,7 @@ public function testResolve(): void

$this->assertSame(
['resolved' => 'data'],
$contentFacade->normalize($contentProjection->reveal())
$contentManager->normalize($contentProjection->reveal())
);
}

Expand All @@ -140,7 +140,7 @@ public function testCopy(): void
$contentCopier = $this->prophesize(ContentCopierInterface::class);
$contentWorkflow = $this->prophesize(ContentWorkflowInterface::class);

$contentFacade = $this->createContentFacadeInstance(
$contentManager = $this->createContentManagerInstance(
$contentResolver->reveal(),
$contentPersister->reveal(),
$contentProjectionNormalizer->reveal(),
Expand All @@ -159,7 +159,7 @@ public function testCopy(): void

$this->assertSame(
$contentProjection->reveal(),
$contentFacade->copy(
$contentManager->copy(
$sourceContentRichEntity->reveal(),
$sourceDimensionAttributes,
$targetContentRichEntity->reveal(),
Expand All @@ -182,7 +182,7 @@ public function testTransition(): void
$contentCopier = $this->prophesize(ContentCopierInterface::class);
$contentWorkflow = $this->prophesize(ContentWorkflowInterface::class);

$contentFacade = $this->createContentFacadeInstance(
$contentManager = $this->createContentManagerInstance(
$contentResolver->reveal(),
$contentPersister->reveal(),
$contentProjectionNormalizer->reveal(),
Expand All @@ -200,7 +200,7 @@ public function testTransition(): void

$this->assertSame(
$contentProjection->reveal(),
$contentFacade->applyTransition(
$contentManager->applyTransition(
$contentRichEntity->reveal(),
$dimensionAttributes,
$transitionName
Expand Down
4 changes: 2 additions & 2 deletions Tests/Unit/DependencyInjection/SuluContentExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractExtensionTestCase;
use Sulu\Bundle\AdminBundle\DependencyInjection\SuluAdminExtension;
use Sulu\Bundle\ContentBundle\Content\Application\ContentCopier\ContentCopierInterface;
use Sulu\Bundle\ContentBundle\Content\Application\ContentFacade\ContentFacadeInterface;
use Sulu\Bundle\ContentBundle\Content\Application\ContentManager\ContentManagerInterface;
use Sulu\Bundle\ContentBundle\Content\Application\ContentPersister\ContentPersisterInterface;
use Sulu\Bundle\ContentBundle\Content\Application\ContentProjectionNormalizer\ContentProjectionNormalizerInterface;
use Sulu\Bundle\ContentBundle\Content\Application\ContentResolver\ContentResolverInterface;
Expand Down Expand Up @@ -56,7 +56,7 @@ public function testLoad(): void
$this->assertContainerBuilderHasParameter('sulu.model.dimension.class', Dimension::class);

// Main services aliases
$this->assertContainerBuilderHasAlias(ContentFacadeInterface::class, 'sulu_content.content_facade');
$this->assertContainerBuilderHasAlias(ContentManagerInterface::class, 'sulu_content.content_manager');
$this->assertContainerBuilderHasAlias(ContentResolverInterface::class, 'sulu_content.content_resolver');
$this->assertContainerBuilderHasAlias(ContentPersisterInterface::class, 'sulu_content.content_persister');
$this->assertContainerBuilderHasAlias(ContentProjectionNormalizerInterface::class, 'sulu_content.content_projection_normalizer');
Expand Down

0 comments on commit 66f4145

Please sign in to comment.