From 66f41455b1bf0795c062a8232a49a7698236fcc5 Mon Sep 17 00:00:00 2001 From: Alexander Schranz Date: Tue, 17 Dec 2019 14:54:04 +0100 Subject: [PATCH] Rename ContentFacade to ContentManager (#68) --- .../ContentManager.php} | 4 +-- .../ContentManagerInterface.php} | 4 +-- Resources/config/services.xml | 6 ++-- .../Controller/ExampleController.php | 22 ++++++------ .../Resources/config/services.yaml | 2 +- .../ContentManagerTest.php} | 34 +++++++++---------- .../SuluContentExtensionTest.php | 4 +-- 7 files changed, 38 insertions(+), 38 deletions(-) rename Content/Application/{ContentFacade/ContentFacade.php => ContentManager/ContentManager.php} (96%) rename Content/Application/{ContentFacade/ContentFacadeInterface.php => ContentManager/ContentManagerInterface.php} (93%) rename Tests/Unit/Content/Application/{ContentFacade/ContentFacadeTest.php => ContentManager/ContentManagerTest.php} (87%) diff --git a/Content/Application/ContentFacade/ContentFacade.php b/Content/Application/ContentManager/ContentManager.php similarity index 96% rename from Content/Application/ContentFacade/ContentFacade.php rename to Content/Application/ContentManager/ContentManager.php index 0d061286..ecbcbaba 100644 --- a/Content/Application/ContentFacade/ContentFacade.php +++ b/Content/Application/ContentManager/ContentManager.php @@ -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; @@ -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 diff --git a/Content/Application/ContentFacade/ContentFacadeInterface.php b/Content/Application/ContentManager/ContentManagerInterface.php similarity index 93% rename from Content/Application/ContentFacade/ContentFacadeInterface.php rename to Content/Application/ContentManager/ContentManagerInterface.php index 07ca841c..1c56714e 100644 --- a/Content/Application/ContentFacade/ContentFacadeInterface.php +++ b/Content/Application/ContentManager/ContentManagerInterface.php @@ -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 diff --git a/Resources/config/services.xml b/Resources/config/services.xml index dbe5fbb0..c587852a 100644 --- a/Resources/config/services.xml +++ b/Resources/config/services.xml @@ -116,8 +116,8 @@ - - + + @@ -125,6 +125,6 @@ - + diff --git a/Tests/Application/ExampleTestBundle/Controller/ExampleController.php b/Tests/Application/ExampleTestBundle/Controller/ExampleController.php index 6918a6dc..1f64675a 100644 --- a/Tests/Application/ExampleTestBundle/Controller/ExampleController.php +++ b/Tests/Application/ExampleTestBundle/Controller/ExampleController.php @@ -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; @@ -50,9 +50,9 @@ class ExampleController extends AbstractRestController implements ClassResourceI private $restHelper; /** - * @var ContentFacadeInterface + * @var ContentManagerInterface */ - private $contentFacade; + private $contentManager; /** * @var EntityManagerInterface @@ -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); @@ -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))); } @@ -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 @@ -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 @@ -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 diff --git a/Tests/Application/ExampleTestBundle/Resources/config/services.yaml b/Tests/Application/ExampleTestBundle/Resources/config/services.yaml index c6202189..8b188e59 100644 --- a/Tests/Application/ExampleTestBundle/Resources/config/services.yaml +++ b/Tests/Application/ExampleTestBundle/Resources/config/services.yaml @@ -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 } diff --git a/Tests/Unit/Content/Application/ContentFacade/ContentFacadeTest.php b/Tests/Unit/Content/Application/ContentManager/ContentManagerTest.php similarity index 87% rename from Tests/Unit/Content/Application/ContentFacade/ContentFacadeTest.php rename to Tests/Unit/Content/Application/ContentManager/ContentManagerTest.php index e2793ef9..872ffa67 100644 --- a/Tests/Unit/Content/Application/ContentFacade/ContentFacadeTest.php +++ b/Tests/Unit/Content/Application/ContentManager/ContentManagerTest.php @@ -11,12 +11,12 @@ * 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; @@ -24,16 +24,16 @@ 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 @@ -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(), @@ -62,7 +62,7 @@ public function testLoad(): void $this->assertSame( $contentProjection->reveal(), - $contentFacade->resolve($contentRichEntity->reveal(), $dimensionAttributes) + $contentManager->resolve($contentRichEntity->reveal(), $dimensionAttributes) ); } @@ -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(), @@ -93,7 +93,7 @@ public function testPersist(): void $this->assertSame( $contentProjection->reveal(), - $contentFacade->persist($contentRichEntity->reveal(), $data, $dimensionAttributes) + $contentManager->persist($contentRichEntity->reveal(), $data, $dimensionAttributes) ); } @@ -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(), @@ -121,7 +121,7 @@ public function testResolve(): void $this->assertSame( ['resolved' => 'data'], - $contentFacade->normalize($contentProjection->reveal()) + $contentManager->normalize($contentProjection->reveal()) ); } @@ -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(), @@ -159,7 +159,7 @@ public function testCopy(): void $this->assertSame( $contentProjection->reveal(), - $contentFacade->copy( + $contentManager->copy( $sourceContentRichEntity->reveal(), $sourceDimensionAttributes, $targetContentRichEntity->reveal(), @@ -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(), @@ -200,7 +200,7 @@ public function testTransition(): void $this->assertSame( $contentProjection->reveal(), - $contentFacade->applyTransition( + $contentManager->applyTransition( $contentRichEntity->reveal(), $dimensionAttributes, $transitionName diff --git a/Tests/Unit/DependencyInjection/SuluContentExtensionTest.php b/Tests/Unit/DependencyInjection/SuluContentExtensionTest.php index ff63f51d..83250f58 100644 --- a/Tests/Unit/DependencyInjection/SuluContentExtensionTest.php +++ b/Tests/Unit/DependencyInjection/SuluContentExtensionTest.php @@ -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; @@ -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');