From 88e86355445d95f788423882a63679fecaf48dc3 Mon Sep 17 00:00:00 2001 From: Alexandre 'pocky' Balmes Date: Sat, 20 Feb 2016 23:17:54 +0100 Subject: [PATCH 1/5] Quick cleanup --- composer.json | 4 +- .../Application/DTO/CreateWebPageDTOSpec.php | 14 +--- .../DTO/CreateWebPageTransformerSpec.php | 8 +-- .../Page/Application/DTO/WebPageDTOSpec.php | 24 ++----- .../DTO/WebPageTransformerSpec.php | 8 +-- .../Application/DTO/WriteWebPageDTOSpec.php | 20 ++---- .../DTO/WriteWebPageTransformerSpec.php | 8 +-- .../PageIsPublishedSpecificationSpec.php | 10 +-- .../Page/Domain/Model/WebPageIdSpec.php | 6 +- .../Page/Domain/Model/WebPageSpec.php | 25 +++---- .../Controller/CreatePageController.php | 66 ----------------- .../Controller/PublishPageController.php | 64 ----------------- .../Controller/ReadPageController.php | 49 ------------- .../Controller/RemovePageController.php | 65 ----------------- .../Controller/WritePageController.php | 70 ------------------ .../PageIsPublishedSpecification.php | 32 --------- .../Domain/Model/WebPageReadRepository.php | 22 ------ .../Domain/Model/WebPageWriteRepository.php | 20 ------ .../CQRS/Command/RemoveWebPageCommand.php | 44 ------------ .../CQRS/Handler/PublishWebPageHandler.php | 72 ------------------- .../Component/Page/WebPageDomainEvents.php | 19 ----- src/Page/Application/Action/CreateWebPage.php | 56 +++++++++++++++ .../Application/Action/PublishWebPage.php | 54 ++++++++++++++ src/Page/Application/Action/ReadWebPage.php | 37 ++++++++++ src/Page/Application/Action/RemoveWebPage.php | 55 ++++++++++++++ src/Page/Application/Action/WriteWebPage.php | 60 ++++++++++++++++ .../DTO/CreateWebPageAssembler.php | 11 ++- .../Page/Application/DTO/CreateWebPageDTO.php | 31 ++------ .../Page/Application/DTO/WebPageAssembler.php | 19 ++--- .../Page/Application/DTO/WebPageDTO.php | 38 +++------- .../Application/DTO/WriteWebPageAssembler.php | 19 ++--- .../Page/Application/DTO/WriteWebPageDTO.php | 41 ++--------- .../Service/WebPageReadService.php | 24 +++---- .../PageIsPublishedSpecification.php | 21 ++++++ .../Page/Domain/Event/WebPageCreatedEvent.php | 15 +--- .../Domain/Event/WebPageDepublishedEvent.php | 15 +--- .../Domain/Event/WebPagePublishedEvent.php | 15 +--- .../Page/Domain/Event/WebPageRemovedEvent.php | 15 +--- .../Page/Domain/Event/WebPageWritedEvent.php | 15 +--- .../Exception/WebPageNotFoundException.php | 14 +--- .../Page/Domain/Listener/LoggerListener.php | 14 ++-- .../Page/Domain/Model/WebPage.php | 40 ++++------- .../Page/Domain/Model/WebPageId.php | 13 +--- .../Domain/Model/WebPageReadRepository.php | 15 ++++ .../Domain/Model/WebPageWriteRepository.php | 13 ++++ src/Page/Domain/WebPageEvents.php | 19 +++++ .../CQRS/Command/CreateWebPageCommand.php | 21 ++---- .../CQRS/Command/DepublishWebPageCommand.php | 15 +--- .../CQRS/Command/PublishWebPageCommand.php | 15 +--- .../CQRS/Command/RemoveWebPageCommand.php | 33 +++++++++ .../CQRS/Command/WriteWebPageCommand.php | 17 +---- .../CQRS/Handler/CreateWebPageHandler.php | 34 +++------ .../CQRS/Handler/DepublishWebPageHandler.php | 34 +++------ .../CQRS/Handler/PublishWebPageHandler.php | 62 ++++++++++++++++ .../CQRS/Handler/RemoveWebPageHandler.php | 34 +++------ .../CQRS/Handler/WriteWebPageHandler.php | 36 ++++------ .../Listener/WebPageCreatedListener.php | 15 +--- .../Listener/WebPageDepublishedListener.php | 15 +--- .../Listener/WebPagePublishedListener.php | 15 +--- .../Listener/WebPageRemovedListener.php | 15 +--- .../Listener/WebPageWritedListener.php | 15 +--- .../Persistence/MongoDB/ReadRepository.php | 6 +- .../Persistence/MongoDB/WriteRepository.php | 6 +- .../Persistence/ORM/ReadRepository.php | 6 +- .../Persistence/ORM/WriteRepository.php | 6 +- .../Service/WebPageReadService.php | 16 ++--- .../Service/WebPageWriteService.php | 20 ++---- 67 files changed, 638 insertions(+), 1117 deletions(-) rename spec/{Black/Component => }/Page/Application/DTO/CreateWebPageDTOSpec.php (73%) rename spec/{Black/Component => }/Page/Application/DTO/CreateWebPageTransformerSpec.php (71%) rename spec/{Black/Component => }/Page/Application/DTO/WebPageDTOSpec.php (72%) rename spec/{Black/Component => }/Page/Application/DTO/WebPageTransformerSpec.php (72%) rename spec/{Black/Component => }/Page/Application/DTO/WriteWebPageDTOSpec.php (70%) rename spec/{Black/Component => }/Page/Application/DTO/WriteWebPageTransformerSpec.php (72%) rename spec/{Black/Component => }/Page/Application/Specification/PageIsPublishedSpecificationSpec.php (58%) rename spec/{Black/Component => }/Page/Domain/Model/WebPageIdSpec.php (81%) rename spec/{Black/Component => }/Page/Domain/Model/WebPageSpec.php (77%) delete mode 100644 src/Black/Component/Page/Application/Controller/CreatePageController.php delete mode 100644 src/Black/Component/Page/Application/Controller/PublishPageController.php delete mode 100644 src/Black/Component/Page/Application/Controller/ReadPageController.php delete mode 100644 src/Black/Component/Page/Application/Controller/RemovePageController.php delete mode 100644 src/Black/Component/Page/Application/Controller/WritePageController.php delete mode 100644 src/Black/Component/Page/Application/Specification/PageIsPublishedSpecification.php delete mode 100644 src/Black/Component/Page/Domain/Model/WebPageReadRepository.php delete mode 100644 src/Black/Component/Page/Domain/Model/WebPageWriteRepository.php delete mode 100644 src/Black/Component/Page/Infrastructure/CQRS/Command/RemoveWebPageCommand.php delete mode 100644 src/Black/Component/Page/Infrastructure/CQRS/Handler/PublishWebPageHandler.php delete mode 100644 src/Black/Component/Page/WebPageDomainEvents.php create mode 100644 src/Page/Application/Action/CreateWebPage.php create mode 100644 src/Page/Application/Action/PublishWebPage.php create mode 100644 src/Page/Application/Action/ReadWebPage.php create mode 100644 src/Page/Application/Action/RemoveWebPage.php create mode 100644 src/Page/Application/Action/WriteWebPage.php rename src/{Black/Component => }/Page/Application/DTO/CreateWebPageAssembler.php (77%) rename src/{Black/Component => }/Page/Application/DTO/CreateWebPageDTO.php (66%) rename src/{Black/Component => }/Page/Application/DTO/WebPageAssembler.php (74%) rename src/{Black/Component => }/Page/Application/DTO/WebPageDTO.php (80%) rename src/{Black/Component => }/Page/Application/DTO/WriteWebPageAssembler.php (72%) rename src/{Black/Component => }/Page/Application/DTO/WriteWebPageDTO.php (62%) rename src/{Black/Component => }/Page/Application/Service/WebPageReadService.php (69%) create mode 100644 src/Page/Application/Specification/PageIsPublishedSpecification.php rename src/{Black/Component => }/Page/Domain/Event/WebPageCreatedEvent.php (56%) rename src/{Black/Component => }/Page/Domain/Event/WebPageDepublishedEvent.php (57%) rename src/{Black/Component => }/Page/Domain/Event/WebPagePublishedEvent.php (57%) rename src/{Black/Component => }/Page/Domain/Event/WebPageRemovedEvent.php (56%) rename src/{Black/Component => }/Page/Domain/Event/WebPageWritedEvent.php (56%) rename src/{Black/Component => }/Page/Domain/Exception/WebPageNotFoundException.php (58%) rename src/{Black/Component => }/Page/Domain/Listener/LoggerListener.php (62%) rename src/{Black/Component => }/Page/Domain/Model/WebPage.php (75%) rename src/{Black/Component => }/Page/Domain/Model/WebPageId.php (62%) create mode 100644 src/Page/Domain/Model/WebPageReadRepository.php create mode 100644 src/Page/Domain/Model/WebPageWriteRepository.php create mode 100644 src/Page/Domain/WebPageEvents.php rename src/{Black/Component => }/Page/Infrastructure/CQRS/Command/CreateWebPageCommand.php (58%) rename src/{Black/Component => }/Page/Infrastructure/CQRS/Command/DepublishWebPageCommand.php (50%) rename src/{Black/Component => }/Page/Infrastructure/CQRS/Command/PublishWebPageCommand.php (50%) create mode 100644 src/Page/Infrastructure/CQRS/Command/RemoveWebPageCommand.php rename src/{Black/Component => }/Page/Infrastructure/CQRS/Command/WriteWebPageCommand.php (69%) rename src/{Black/Component => }/Page/Infrastructure/CQRS/Handler/CreateWebPageHandler.php (52%) rename src/{Black/Component => }/Page/Infrastructure/CQRS/Handler/DepublishWebPageHandler.php (50%) create mode 100644 src/Page/Infrastructure/CQRS/Handler/PublishWebPageHandler.php rename src/{Black/Component => }/Page/Infrastructure/CQRS/Handler/RemoveWebPageHandler.php (51%) rename src/{Black/Component => }/Page/Infrastructure/CQRS/Handler/WriteWebPageHandler.php (58%) rename src/{Black/Component => }/Page/Infrastructure/Listener/WebPageCreatedListener.php (61%) rename src/{Black/Component => }/Page/Infrastructure/Listener/WebPageDepublishedListener.php (61%) rename src/{Black/Component => }/Page/Infrastructure/Listener/WebPagePublishedListener.php (60%) rename src/{Black/Component => }/Page/Infrastructure/Listener/WebPageRemovedListener.php (60%) rename src/{Black/Component => }/Page/Infrastructure/Listener/WebPageWritedListener.php (60%) rename src/{Black/Component => }/Page/Infrastructure/Persistence/MongoDB/ReadRepository.php (87%) rename src/{Black/Component => }/Page/Infrastructure/Persistence/MongoDB/WriteRepository.php (79%) rename src/{Black/Component => }/Page/Infrastructure/Persistence/ORM/ReadRepository.php (88%) rename src/{Black/Component => }/Page/Infrastructure/Persistence/ORM/WriteRepository.php (83%) rename src/{Black/Component => }/Page/Infrastructure/Service/WebPageReadService.php (68%) rename src/{Black/Component => }/Page/Infrastructure/Service/WebPageWriteService.php (81%) diff --git a/composer.json b/composer.json index c0085bf..4f9019d 100644 --- a/composer.json +++ b/composer.json @@ -25,8 +25,8 @@ "require": { "php": ">=5.4.0", "monolog/monolog": "~1.10", - "symfony/event-dispatcher": "~2.5", - "symfony/http-kernel": "~2.5", + "symfony/event-dispatcher": "~2.5|~3.0", + "symfony/http-kernel": "~2.5|~3.0", "black/common": "~2.0.0", "cocur/slugify": "~1.0" }, diff --git a/spec/Black/Component/Page/Application/DTO/CreateWebPageDTOSpec.php b/spec/Page/Application/DTO/CreateWebPageDTOSpec.php similarity index 73% rename from spec/Black/Component/Page/Application/DTO/CreateWebPageDTOSpec.php rename to spec/Page/Application/DTO/CreateWebPageDTOSpec.php index 2d09db5..bdf1c67 100644 --- a/spec/Black/Component/Page/Application/DTO/CreateWebPageDTOSpec.php +++ b/spec/Page/Application/DTO/CreateWebPageDTOSpec.php @@ -1,6 +1,6 @@ shouldHaveType('Black\Component\Page\Application\DTO\CreateWebPageDTO'); + $this->shouldHaveType('Black\Page\Application\DTO\CreateWebPageDTO'); } public function it_should_return_id() @@ -41,16 +41,6 @@ public function it_should_return_name() $this->getName()->shouldReturn($this->name); } - public function it_should_return_context() - { - $this->getContext()->shouldReturn("http://schema.org"); - } - - public function it_should_return_type() - { - $this->getType()->shouldReturn("WebPage"); - } - public function it_should_serialize() { $this->serialize()->shouldBeString(); diff --git a/spec/Black/Component/Page/Application/DTO/CreateWebPageTransformerSpec.php b/spec/Page/Application/DTO/CreateWebPageTransformerSpec.php similarity index 71% rename from spec/Black/Component/Page/Application/DTO/CreateWebPageTransformerSpec.php rename to spec/Page/Application/DTO/CreateWebPageTransformerSpec.php index d93bcfb..ba95fbb 100644 --- a/spec/Black/Component/Page/Application/DTO/CreateWebPageTransformerSpec.php +++ b/spec/Page/Application/DTO/CreateWebPageTransformerSpec.php @@ -1,8 +1,8 @@ entityClass = 'Black\Component\Page\Domain\Model\WebPage'; - $this->dtoClass = 'Black\Component\Page\Application\DTO\CreateWebPageDTO'; + $this->entityClass = 'Black\Page\Domain\Model\WebPage'; + $this->dtoClass = 'Black\Page\Application\DTO\CreateWebPageDTO'; $this->beConstructedWith($this->entityClass, $this->dtoClass); } diff --git a/spec/Black/Component/Page/Application/DTO/WebPageDTOSpec.php b/spec/Page/Application/DTO/WebPageDTOSpec.php similarity index 72% rename from spec/Black/Component/Page/Application/DTO/WebPageDTOSpec.php rename to spec/Page/Application/DTO/WebPageDTOSpec.php index bb85c7c..03c5ac2 100644 --- a/spec/Black/Component/Page/Application/DTO/WebPageDTOSpec.php +++ b/spec/Page/Application/DTO/WebPageDTOSpec.php @@ -1,6 +1,6 @@ id = 1; - $this->author = 'test'; - $this->name = 'test'; + $this->id = 1; + $this->author = 'test'; + $this->name = 'test'; $this->headline = 'test'; - $this->about = 'test'; - $this->text = 'test'; + $this->about = 'test'; + $this->text = 'test'; $this->beConstructedWith($this->id, $this->author, $this->name, $this->headline, $this->about, $this->text); } public function it_is_initializable() { - $this->shouldHaveType('Black\Component\Page\Application\DTO\WebPageDTO'); + $this->shouldHaveType('Black\Page\Application\DTO\WebPageDTO'); } public function it_should_return_id() @@ -65,16 +65,6 @@ public function it_should_return_text() $this->getText()->shouldReturn($this->text); } - public function it_should_return_context() - { - $this->getContext()->shouldReturn("http://schema.org"); - } - - public function it_should_return_type() - { - $this->getType()->shouldReturn("WebPage"); - } - public function it_should_serialize() { $this->serialize()->shouldBeString(); diff --git a/spec/Black/Component/Page/Application/DTO/WebPageTransformerSpec.php b/spec/Page/Application/DTO/WebPageTransformerSpec.php similarity index 72% rename from spec/Black/Component/Page/Application/DTO/WebPageTransformerSpec.php rename to spec/Page/Application/DTO/WebPageTransformerSpec.php index 19fbb2a..3fbb911 100644 --- a/spec/Black/Component/Page/Application/DTO/WebPageTransformerSpec.php +++ b/spec/Page/Application/DTO/WebPageTransformerSpec.php @@ -1,8 +1,8 @@ entityClass = 'Black\Component\Page\Domain\Model\WebPage'; - $this->dtoClass = 'Black\Component\Page\Application\DTO\WebPageDTO'; + $this->entityClass = 'Black\Page\Domain\Model\WebPage'; + $this->dtoClass = 'Black\Page\Application\DTO\WebPageDTO'; $this->beConstructedWith($this->entityClass, $this->dtoClass); } diff --git a/spec/Black/Component/Page/Application/DTO/WriteWebPageDTOSpec.php b/spec/Page/Application/DTO/WriteWebPageDTOSpec.php similarity index 70% rename from spec/Black/Component/Page/Application/DTO/WriteWebPageDTOSpec.php rename to spec/Page/Application/DTO/WriteWebPageDTOSpec.php index 4f57c55..a2e9597 100644 --- a/spec/Black/Component/Page/Application/DTO/WriteWebPageDTOSpec.php +++ b/spec/Page/Application/DTO/WriteWebPageDTOSpec.php @@ -1,6 +1,6 @@ id = 1; + $this->id = 1; $this->headline = 'test'; - $this->about = 'test'; - $this->text = 'test'; + $this->about = 'test'; + $this->text = 'test'; $this->beConstructedWith($this->id, $this->headline, $this->about, $this->text); } public function it_is_initializable() { - $this->shouldHaveType('Black\Component\Page\Application\DTO\WriteWebPageDTO'); + $this->shouldHaveType('Black\Page\Application\DTO\WriteWebPageDTO'); } public function it_should_return_id() @@ -49,16 +49,6 @@ public function it_should_return_text() $this->getText()->shouldReturn($this->text); } - public function it_should_return_context() - { - $this->getContext()->shouldReturn("http://schema.org"); - } - - public function it_should_return_type() - { - $this->getType()->shouldReturn("WebPage"); - } - public function it_should_serialize() { $this->serialize()->shouldBeString(); diff --git a/spec/Black/Component/Page/Application/DTO/WriteWebPageTransformerSpec.php b/spec/Page/Application/DTO/WriteWebPageTransformerSpec.php similarity index 72% rename from spec/Black/Component/Page/Application/DTO/WriteWebPageTransformerSpec.php rename to spec/Page/Application/DTO/WriteWebPageTransformerSpec.php index 88e0fad..a988c3f 100644 --- a/spec/Black/Component/Page/Application/DTO/WriteWebPageTransformerSpec.php +++ b/spec/Page/Application/DTO/WriteWebPageTransformerSpec.php @@ -1,8 +1,8 @@ entityClass = 'Black\Component\Page\Domain\Model\WebPage'; - $this->dtoClass = 'Black\Component\Page\Application\DTO\WriteWebPageDTO'; + $this->entityClass = 'Black\Page\Domain\Model\WebPage'; + $this->dtoClass = 'Black\Page\Application\DTO\WriteWebPageDTO'; $this->beConstructedWith($this->entityClass, $this->dtoClass); } diff --git a/spec/Black/Component/Page/Application/Specification/PageIsPublishedSpecificationSpec.php b/spec/Page/Application/Specification/PageIsPublishedSpecificationSpec.php similarity index 58% rename from spec/Black/Component/Page/Application/Specification/PageIsPublishedSpecificationSpec.php rename to spec/Page/Application/Specification/PageIsPublishedSpecificationSpec.php index 8e8d4e6..b6302df 100644 --- a/spec/Black/Component/Page/Application/Specification/PageIsPublishedSpecificationSpec.php +++ b/spec/Page/Application/Specification/PageIsPublishedSpecificationSpec.php @@ -1,9 +1,9 @@ shouldHaveType('Black\Component\Page\Application\Specification\PageIsPublishedSpecification'); + $this->shouldHaveType('Black\Page\Application\Specification\PageIsPublishedSpecification'); } public function let() { $pageId = new WebPageId('12345'); - $page = new WebPage($pageId, 'test', 'test'); + $page = new WebPage($pageId, 'test', 'test', 'test'); $this->page = $page; } diff --git a/spec/Black/Component/Page/Domain/Model/WebPageIdSpec.php b/spec/Page/Domain/Model/WebPageIdSpec.php similarity index 81% rename from spec/Black/Component/Page/Domain/Model/WebPageIdSpec.php rename to spec/Page/Domain/Model/WebPageIdSpec.php index 95b8bb0..9410b72 100644 --- a/spec/Black/Component/Page/Domain/Model/WebPageIdSpec.php +++ b/spec/Page/Domain/Model/WebPageIdSpec.php @@ -1,8 +1,8 @@ shouldHaveType('Black\Component\Page\Domain\Model\WebPageId'); + $this->shouldHaveType('Black\Page\Domain\Model\WebPageId'); } public function it_should_have_a_value() diff --git a/spec/Black/Component/Page/Domain/Model/WebPageSpec.php b/spec/Page/Domain/Model/WebPageSpec.php similarity index 77% rename from spec/Black/Component/Page/Domain/Model/WebPageSpec.php rename to spec/Page/Domain/Model/WebPageSpec.php index f2af7fb..1ca1337 100644 --- a/spec/Black/Component/Page/Domain/Model/WebPageSpec.php +++ b/spec/Page/Domain/Model/WebPageSpec.php @@ -1,9 +1,9 @@ webPageId = $page->getWebPageId(); - $this->name = $page->getName(); - $this->author = $page->getAuthor(); + $this->name = $page->getName(); + $this->author = $page->getAuthor(); + $this->slug = $page->getSlug(); - $this->beConstructedWith($this->webPageId, $this->name, $this->author); + $this->beConstructedWith($this->webPageId, $this->name, $this->author, $this->slug); } public function it_is_initializable() { - $this->shouldHaveType('Black\Component\Page\Domain\Model\WebPage'); + $this->shouldHaveType('Black\Page\Domain\Model\WebPage'); } public function it_should_have_a_dateCreated() @@ -63,8 +64,8 @@ public function it_should_not_be_published() public function it_should_be_write() { $this->headline = "headline"; - $this->about = "about"; - $this->text = "text"; + $this->about = "about"; + $this->text = "text"; $this->write($this->headline, $this->about, $this->text); @@ -76,8 +77,8 @@ public function it_should_be_write() public function it_should_be_edited() { $this->headline = "headline 2"; - $this->about = "about 2"; - $this->text = "text 2"; + $this->about = "about 2"; + $this->text = "text 2"; $this->write($this->headline, $this->about, $this->text); diff --git a/src/Black/Component/Page/Application/Controller/CreatePageController.php b/src/Black/Component/Page/Application/Controller/CreatePageController.php deleted file mode 100644 index 7ffc79d..0000000 --- a/src/Black/Component/Page/Application/Controller/CreatePageController.php +++ /dev/null @@ -1,66 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Black\Component\Page\Application\Controller; - -use Black\Component\Page\Domain\Model\WebPageId; -use Black\Component\Page\Infrastructure\CQRS\Handler\CreateWebPageHandler; -use Black\DDD\CQRSinPHP\Infrastructure\CQRS\Bus; - -/** - * Class CreatePageController - * - * @author Alexandre 'pocky' Balmes - * @license http://opensource.org/licenses/mit-license.php MIT - */ -class CreatePageController -{ - /** - * @var \Black\DDD\CQRSinPHP\Infrastructure\CQRS\Bus - */ - protected $bus; - - /** - * @var - */ - protected $commandName; - - /** - * @var \Black\Component\Page\Infrastructure\CQRS\Handler\CreateWebPageHandler - */ - protected $handler; - - /** - * @param Bus $bus - * @param CreateWebPageHandler $handler - * @param $commandName - */ - public function __construct( - Bus $bus, - CreateWebPageHandler $handler, - $commandName - ) { - $this->bus = $bus; - $this->handler = $handler; - $this->commandName = $commandName; - } - - /** - * @param WebPageId $id - * @param $author - * @param $name - */ - public function createPageAction(WebPageId $id, $author, $name) - { - $this->bus->register($this->commandName, $this->handler); - $this->bus->handle(new $this->commandName($id, $author, $name)); - } -} diff --git a/src/Black/Component/Page/Application/Controller/PublishPageController.php b/src/Black/Component/Page/Application/Controller/PublishPageController.php deleted file mode 100644 index 66ca8f4..0000000 --- a/src/Black/Component/Page/Application/Controller/PublishPageController.php +++ /dev/null @@ -1,64 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Black\Component\Page\Application\Controller; - -use Black\Component\Page\Domain\Model\WebPageId; -use Black\Component\Page\Infrastructure\CQRS\Handler\PublishWebPageHandler; -use Black\DDD\CQRSinPHP\Infrastructure\CQRS\Bus; - -/** - * Class PublishPageController - * - * @author Alexandre 'pocky' Balmes - * @license http://opensource.org/licenses/mit-license.php MIT - */ -class PublishPageController -{ - /** - * @var \Black\DDD\CQRSinPHP\Infrastructure\CQRS\Bus - */ - protected $bus; - - /** - * @var - */ - protected $commandName; - - /** - * @var \Black\Component\Page\Infrastructure\CQRS\Handler\PublishWebPageHandler - */ - protected $handler; - - /** - * @param Bus $bus - * @param PublishWebPageHandler $handler - * @param $commandName - */ - public function __construct( - Bus $bus, - PublishWebPageHandler $handler, - $commandName - ) { - $this->bus = $bus; - $this->handler = $handler; - $this->commandName = $commandName; - } - - /** - * @param WebPageId $id - */ - public function publishPageAction(WebPageId $id) - { - $this->bus->register($this->commandName, $this->handler); - $this->bus->handle(new $this->commandName($id)); - } -} diff --git a/src/Black/Component/Page/Application/Controller/ReadPageController.php b/src/Black/Component/Page/Application/Controller/ReadPageController.php deleted file mode 100644 index 2a8184d..0000000 --- a/src/Black/Component/Page/Application/Controller/ReadPageController.php +++ /dev/null @@ -1,49 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Black\Component\Page\Application\Controller; - -use Black\Component\Page\Application\Service\WebPageReadService; -use Black\Component\Page\Domain\Model\WebPageId; - -/** - * Class ReadPageController - * - * @author Alexandre 'pocky' Balmes - * @license http://opensource.org/licenses/mit-license.php MIT - */ -class ReadPageController -{ - /** - * @var \Black\Component\Page\Application\Service\WebPageReadService - */ - protected $service; - - /** - * @param WebPageReadService $service - */ - public function __construct(WebPageReadService $service) - { - $this->service = $service; - } - - /** - * @param WebPageId $id - * - * @return \Black\Component\Page\Application\DTO\WebPageDTO - */ - public function readPageAction(WebPageId $id) - { - $page = $this->service->read($id); - - return $page; - } -} diff --git a/src/Black/Component/Page/Application/Controller/RemovePageController.php b/src/Black/Component/Page/Application/Controller/RemovePageController.php deleted file mode 100644 index 5fcbd1b..0000000 --- a/src/Black/Component/Page/Application/Controller/RemovePageController.php +++ /dev/null @@ -1,65 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Black\Component\Page\Application\Controller; - -use Black\Component\Page\Domain\Model\WebPage; -use Black\Component\Page\Domain\Model\WebPageId; -use Black\Component\Page\Infrastructure\CQRS\Handler\RemoveWebPageHandler; -use Black\DDD\CQRSinPHP\Infrastructure\CQRS\Bus; - -/** - * Class RemovePageController - * - * @author Alexandre 'pocky' Balmes - * @license http://opensource.org/licenses/mit-license.php MIT - */ -class RemovePageController -{ - /** - * @var \Black\DDD\CQRSinPHP\Infrastructure\CQRS\Bus - */ - protected $bus; - - /** - * @var - */ - protected $commandName; - - /** - * @var \Black\Component\Page\Infrastructure\CQRS\Handler\RemoveWebPageHandler - */ - protected $handler; - - /** - * @param Bus $bus - * @param RemoveWebPageHandler $handler - * @param $commandName - */ - public function __construct( - Bus $bus, - RemoveWebPageHandler $handler, - $commandName - ) { - $this->bus = $bus; - $this->handler = $handler; - $this->commandName = $commandName; - } - - /** - * @param WebPageId $id - */ - public function removePageAction(WebPage $page) - { - $this->bus->register($this->commandName, $this->handler); - $this->bus->handle(new $this->commandName($page)); - } -} diff --git a/src/Black/Component/Page/Application/Controller/WritePageController.php b/src/Black/Component/Page/Application/Controller/WritePageController.php deleted file mode 100644 index 1b15818..0000000 --- a/src/Black/Component/Page/Application/Controller/WritePageController.php +++ /dev/null @@ -1,70 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Black\Component\Page\Application\Controller; - -use Black\Component\Page\Application\DTO\WriteWebPageDTO; -use Black\Component\Page\Domain\Model\WebPageId; -use Black\Component\Page\Infrastructure\CQRS\Handler\WriteWebPageHandler; -use Black\DDD\CQRSinPHP\Infrastructure\CQRS\Bus; - -/** - * Class WritePageController - * - * @author Alexandre 'pocky' Balmes - * @license http://opensource.org/licenses/mit-license.php MIT - */ -class WritePageController -{ - /** - * @var \Black\DDD\CQRSinPHP\Infrastructure\CQRS\Bus - */ - protected $bus; - - /** - * @var - */ - protected $commandName; - - /** - * @var \Black\Component\Page\Infrastructure\CQRS\Handler\WriteWebPageHandler - */ - protected $handler; - - /** - * @param Bus $bus - * @param WriteWebPageHandler $handler - * @param $commandName - */ - public function __construct( - Bus $bus, - WriteWebPageHandler $handler, - $commandName - ) { - $this->bus = $bus; - $this->handler = $handler; - $this->commandName = $commandName; - } - - /** - * @param WriteWebPageDTO $dto - */ - public function writePageAction(WriteWebPageDTO $dto) - { - $this->bus->register($this->commandName, $this->handler); - $this->bus->handle(new $this->commandName( - new WebPageId($dto->getId()), - $dto->getHeadline(), - $dto->getAbout(), - $dto->getText() - )); - } -} diff --git a/src/Black/Component/Page/Application/Specification/PageIsPublishedSpecification.php b/src/Black/Component/Page/Application/Specification/PageIsPublishedSpecification.php deleted file mode 100644 index bdd3d76..0000000 --- a/src/Black/Component/Page/Application/Specification/PageIsPublishedSpecification.php +++ /dev/null @@ -1,32 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Black\Component\Page\Application\Specification; - -use Black\Component\Page\Domain\Model\WebPage; - -/** - * Class PageIsPublishedSpecification - * - * @author Alexandre 'pocky' Balmes - * @license http://opensource.org/licenses/mit-license.php MIT - */ -final class PageIsPublishedSpecification -{ - /** - * @param WebPage $webPage - * - * @return bool - */ - public function isSatisfiedBy(WebPage $webPage) - { - return (bool) true === $webPage->isPublished(); - } -} diff --git a/src/Black/Component/Page/Domain/Model/WebPageReadRepository.php b/src/Black/Component/Page/Domain/Model/WebPageReadRepository.php deleted file mode 100644 index 08f2eda..0000000 --- a/src/Black/Component/Page/Domain/Model/WebPageReadRepository.php +++ /dev/null @@ -1,22 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Black\Component\Page\Infrastructure\CQRS\Command; - -use Black\Component\Page\Domain\Model\WebPage; -use Black\DDD\CQRSinPHP\Infrastructure\CQRS\Command; - -/** - * Class RemoveWebPageCommand - * - * @author Alexandre 'pocky' Balmes - * @license http://opensource.org/licenses/mit-license.php MIT - */ -final class RemoveWebPageCommand implements Command -{ - /** - * @var - */ - private $webPage; - - /** - * @param WebPage $webPage - */ - public function __construct(WebPage $webPage) - { - $this->webPage = $webPage; - } - - /** - * @return mixed - */ - public function getWebPage() - { - return $this->webPage; - } -} diff --git a/src/Black/Component/Page/Infrastructure/CQRS/Handler/PublishWebPageHandler.php b/src/Black/Component/Page/Infrastructure/CQRS/Handler/PublishWebPageHandler.php deleted file mode 100644 index d1cf27d..0000000 --- a/src/Black/Component/Page/Infrastructure/CQRS/Handler/PublishWebPageHandler.php +++ /dev/null @@ -1,72 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Black\Component\Page\Infrastructure\CQRS\Handler; - -use Black\Component\Page\Domain\Model\WebPageWriteRepository; -use Black\Component\Page\Infrastructure\CQRS\Command\PublishWebPageCommand; -use Black\Component\Page\Domain\Event\WebPagePublishedEvent; -use Black\Component\Page\Infrastructure\Service\WebPageWriteService; -use Black\Component\Page\WebPageDomainEvents; -use Black\DDD\CQRSinPHP\Infrastructure\CQRS\CommandHandler; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; - -/** - * Class PublishWebPageHandler - * - * @author Alexandre 'pocky' Balmes - * @license http://opensource.org/licenses/mit-license.php MIT - */ -final class PublishWebPageHandler implements CommandHandler -{ - /** - * @var WebPageWriteService - */ - protected $service; - - /** - * @var WebPageReadRepository - */ - protected $repository; - - /** - * @var EventDispatcherInterface - */ - protected $eventDispatcher; - - /** - * @param WebPageWriteService $service - * @param WebPageReadRepository $repository - * @param EventDispatcherInterface $eventDispatcher - */ - public function __construct( - WebPageWriteService $service, - WebPageWriteRepository $repository, - EventDispatcherInterface $eventDispatcher - ) { - $this->service = $service; - $this->repository = $repository; - $this->eventDispatcher = $eventDispatcher; - } - - /** - * @param PublishWebPageCommand $command - * @return mixed - */ - public function handle(PublishWebPageCommand $command) - { - $page = $this->service->publish($command->getWebPage()); - - $this->repository->flush(); - - $event = new WebPagePublishedEvent($page->getWebPageId()->getValue(), $page->getName()); - $this->eventDispatcher->dispatch(WebPageDomainEvents::WEBPAGE_DOMAIN_PUBLISHED, $event); - } -} diff --git a/src/Black/Component/Page/WebPageDomainEvents.php b/src/Black/Component/Page/WebPageDomainEvents.php deleted file mode 100644 index fc3de08..0000000 --- a/src/Black/Component/Page/WebPageDomainEvents.php +++ /dev/null @@ -1,19 +0,0 @@ -bus = $bus; + $this->handler = $handler; + $this->commandName = $commandName; + } + + /** + * @param WebPageId $id + * @param $author + * @param $name + */ + public function __invoke(WebPageId $id, $author, $name) + { + $this->bus->register($this->commandName, $this->handler); + $this->bus->handle(new $this->commandName($id, $author, $name)); + } +} diff --git a/src/Page/Application/Action/PublishWebPage.php b/src/Page/Application/Action/PublishWebPage.php new file mode 100644 index 0000000..aae1088 --- /dev/null +++ b/src/Page/Application/Action/PublishWebPage.php @@ -0,0 +1,54 @@ +bus = $bus; + $this->handler = $handler; + $this->commandName = $commandName; + } + + /** + * @param WebPageId $id + */ + public function __invoke(WebPageId $id) + { + $this->bus->register($this->commandName, $this->handler); + $this->bus->handle(new $this->commandName($id)); + } +} diff --git a/src/Page/Application/Action/ReadWebPage.php b/src/Page/Application/Action/ReadWebPage.php new file mode 100644 index 0000000..de37b28 --- /dev/null +++ b/src/Page/Application/Action/ReadWebPage.php @@ -0,0 +1,37 @@ +service = $service; + } + + /** + * @param WebPageId $id + * + * @return \Black\Page\Application\DTO\WebPageDTO + */ + public function __invoke(WebPageId $id) + { + $page = $this->service->read($id); + + return $page; + } +} diff --git a/src/Page/Application/Action/RemoveWebPage.php b/src/Page/Application/Action/RemoveWebPage.php new file mode 100644 index 0000000..0db124e --- /dev/null +++ b/src/Page/Application/Action/RemoveWebPage.php @@ -0,0 +1,55 @@ +bus = $bus; + $this->handler = $handler; + $this->commandName = $commandName; + } + + /** + * @param WebPage $page + */ + public function __invoke(WebPage $page) + { + $this->bus->register($this->commandName, $this->handler); + $this->bus->handle(new $this->commandName($page)); + } +} diff --git a/src/Page/Application/Action/WriteWebPage.php b/src/Page/Application/Action/WriteWebPage.php new file mode 100644 index 0000000..d1b32c5 --- /dev/null +++ b/src/Page/Application/Action/WriteWebPage.php @@ -0,0 +1,60 @@ +bus = $bus; + $this->handler = $handler; + $this->commandName = $commandName; + } + + /** + * @param WriteWebPageDTO $dto + */ + public function __invoke(WriteWebPageDTO $dto) + { + $this->bus->register($this->commandName, $this->handler); + $this->bus->handle(new $this->commandName( + new WebPageId($dto->getId()), + $dto->getHeadline(), + $dto->getAbout(), + $dto->getText() + )); + } +} diff --git a/src/Black/Component/Page/Application/DTO/CreateWebPageAssembler.php b/src/Page/Application/DTO/CreateWebPageAssembler.php similarity index 77% rename from src/Black/Component/Page/Application/DTO/CreateWebPageAssembler.php rename to src/Page/Application/DTO/CreateWebPageAssembler.php index 81cb1e1..a8e85ee 100644 --- a/src/Black/Component/Page/Application/DTO/CreateWebPageAssembler.php +++ b/src/Page/Application/DTO/CreateWebPageAssembler.php @@ -1,15 +1,12 @@ - * @license http://opensource.org/licenses/mit-license.php MIT */ class CreateWebPageAssembler { @@ -30,7 +27,7 @@ class CreateWebPageAssembler public function __construct($entityClass, $dtoClass) { $this->entityClass = $entityClass; - $this->dtoClass = $dtoClass; + $this->dtoClass = $dtoClass; } /** diff --git a/src/Black/Component/Page/Application/DTO/CreateWebPageDTO.php b/src/Page/Application/DTO/CreateWebPageDTO.php similarity index 66% rename from src/Black/Component/Page/Application/DTO/CreateWebPageDTO.php rename to src/Page/Application/DTO/CreateWebPageDTO.php index d605117..dd26a38 100644 --- a/src/Black/Component/Page/Application/DTO/CreateWebPageDTO.php +++ b/src/Page/Application/DTO/CreateWebPageDTO.php @@ -1,12 +1,9 @@ - * @license http://opensource.org/licenses/mit-license.php MIT */ final class CreateWebPageDTO { @@ -42,11 +39,9 @@ final class CreateWebPageDTO */ public function __construct($id, $author, $name) { - $this->id = $id; - $this->author = $author; - $this->name = $name; - $this->context = "http://schema.org"; - $this->type = "WebPage"; + $this->id = $id; + $this->author = $author; + $this->name = $name; } /** @@ -73,22 +68,6 @@ public function getName() return $this->name; } - /** - * @return string - */ - public function getContext() - { - return $this->context; - } - - /** - * @return string - */ - public function getType() - { - return $this->type; - } - /** * @return string */ @@ -98,8 +77,6 @@ public function serialize() $this->id, $this->author, $this->name, - $this->context, - $this->type, ]); } diff --git a/src/Black/Component/Page/Application/DTO/WebPageAssembler.php b/src/Page/Application/DTO/WebPageAssembler.php similarity index 74% rename from src/Black/Component/Page/Application/DTO/WebPageAssembler.php rename to src/Page/Application/DTO/WebPageAssembler.php index 7e21818..ac1aaeb 100644 --- a/src/Black/Component/Page/Application/DTO/WebPageAssembler.php +++ b/src/Page/Application/DTO/WebPageAssembler.php @@ -1,23 +1,12 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -namespace Black\Component\Page\Application\DTO; +namespace Black\Page\Application\DTO; -use Black\Component\Page\Domain\Model\WebPage; -use Black\Component\Page\Domain\Model\WebPageId; +use Black\Page\Domain\Model\WebPage; +use Black\Page\Domain\Model\WebPageId; /** * Class WebPageAssembler - * - * @author Alexandre 'pocky' Balmes - * @license http://opensource.org/licenses/mit-license.php MIT */ class WebPageAssembler { @@ -38,7 +27,7 @@ class WebPageAssembler public function __construct($entityClass, $dtoClass) { $this->entityClass = $entityClass; - $this->dtoClass = $dtoClass; + $this->dtoClass = $dtoClass; } /** diff --git a/src/Black/Component/Page/Application/DTO/WebPageDTO.php b/src/Page/Application/DTO/WebPageDTO.php similarity index 80% rename from src/Black/Component/Page/Application/DTO/WebPageDTO.php rename to src/Page/Application/DTO/WebPageDTO.php index 1c72010..c2cdd34 100644 --- a/src/Black/Component/Page/Application/DTO/WebPageDTO.php +++ b/src/Page/Application/DTO/WebPageDTO.php @@ -8,7 +8,7 @@ * file that was distributed with this source code. */ -namespace Black\Component\Page\Application\DTO; +namespace Black\Page\Application\DTO; /** * Class WebPageDTO @@ -78,16 +78,14 @@ final class WebPageDTO */ public function __construct($id, $author, $name = 'New WebPage!', $headline = null, $about = null, $text = null) { - $this->id = $id; - $this->author = $author; - $this->name = $name; - $this->headline = $headline; - $this->about = $about; - $this->text = $text; - $this->creator = $author; - $this->editor = $author; - $this->context = "http://schema.org"; - $this->type = "WebPage"; + $this->id = $id; + $this->author = $author; + $this->name = $name; + $this->headline = $headline; + $this->about = $about; + $this->text = $text; + $this->creator = $author; + $this->editor = $author; } /** @@ -154,22 +152,6 @@ public function getEditor() return $this->editor; } - /** - * @return string - */ - public function getContext() - { - return $this->context; - } - - /** - * @return string - */ - public function getType() - { - return $this->type; - } - /** * @return string */ @@ -184,8 +166,6 @@ public function serialize() $this->text, $this->creator, $this->editor, - $this->context, - $this->type, ]); } diff --git a/src/Black/Component/Page/Application/DTO/WriteWebPageAssembler.php b/src/Page/Application/DTO/WriteWebPageAssembler.php similarity index 72% rename from src/Black/Component/Page/Application/DTO/WriteWebPageAssembler.php rename to src/Page/Application/DTO/WriteWebPageAssembler.php index 84f78ff..510f224 100644 --- a/src/Black/Component/Page/Application/DTO/WriteWebPageAssembler.php +++ b/src/Page/Application/DTO/WriteWebPageAssembler.php @@ -1,18 +1,13 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -namespace Black\Component\Page\Application\DTO; +namespace Black\Page\Application\DTO; -use Black\Component\Page\Domain\Model\WebPage; -use Black\Component\Page\Domain\Model\WebPageId; +use Black\Page\Domain\Model\WebPage; +use Black\Page\Domain\Model\WebPageId; +/** + * Class WriteWebPageAssembler + */ class WriteWebPageAssembler { /** @@ -32,7 +27,7 @@ class WriteWebPageAssembler public function __construct($entityClass, $dtoClass) { $this->entityClass = $entityClass; - $this->dtoClass = $dtoClass; + $this->dtoClass = $dtoClass; } /** diff --git a/src/Black/Component/Page/Application/DTO/WriteWebPageDTO.php b/src/Page/Application/DTO/WriteWebPageDTO.php similarity index 62% rename from src/Black/Component/Page/Application/DTO/WriteWebPageDTO.php rename to src/Page/Application/DTO/WriteWebPageDTO.php index 43a7911..9fe4b89 100644 --- a/src/Black/Component/Page/Application/DTO/WriteWebPageDTO.php +++ b/src/Page/Application/DTO/WriteWebPageDTO.php @@ -1,20 +1,9 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -namespace Black\Component\Page\Application\DTO; +namespace Black\Page\Application\DTO; /** * Class WriteWebPage - * - * @author Alexandre 'pocky' Balmes - * @license http://opensource.org/licenses/mit-license.php MIT */ final class WriteWebPageDTO { @@ -56,12 +45,10 @@ final class WriteWebPageDTO */ public function __construct($id, $headline, $about, $text) { - $this->id = $id; - $this->headline = $headline; - $this->about = $about; - $this->text = $text; - $this->context = "http://schema.org"; - $this->type = "WebPage"; + $this->id = $id; + $this->headline = $headline; + $this->about = $about; + $this->text = $text; } /** @@ -96,22 +83,6 @@ public function getText() return $this->text; } - /** - * @return string - */ - public function getContext() - { - return $this->context; - } - - /** - * @return string - */ - public function getType() - { - return $this->type; - } - /** * @return string */ @@ -122,8 +93,6 @@ public function serialize() $this->headline, $this->about, $this->text, - $this->context, - $this->type, ]); } diff --git a/src/Black/Component/Page/Application/Service/WebPageReadService.php b/src/Page/Application/Service/WebPageReadService.php similarity index 69% rename from src/Black/Component/Page/Application/Service/WebPageReadService.php rename to src/Page/Application/Service/WebPageReadService.php index d0f3ab1..1b8194c 100644 --- a/src/Black/Component/Page/Application/Service/WebPageReadService.php +++ b/src/Page/Application/Service/WebPageReadService.php @@ -1,21 +1,13 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -namespace Black\Component\Page\Application\Service; +namespace Black\Page\Application\Service; use Black\Component\Common\Application\Specification\Specification; -use Black\Component\Page\Application\DTO\WebPageAssembler; -use Black\Component\Page\Application\DTO\WebPageDTO; -use Black\Component\Page\Application\Specification\PageIsPublishedSpecification; -use Black\Component\Page\Domain\Model\WebPage; -use Black\Component\Page\Infrastructure\Service\WebPageReadService as InfrastructureService; +use Black\Page\Application\DTO\WebPageAssembler; +use Black\Page\Application\DTO\WebPageDTO; +use Black\Page\Application\Specification\PageIsPublishedSpecification; +use Black\Page\Domain\Model\WebPage; +use Black\Page\Infrastructure\Service\WebPageReadService as InfrastructureService; class WebPageReadService { @@ -72,6 +64,10 @@ public function readBySlug($slug) return $this->checkSatisfaction($page); } + /** + * @param WebPage $page + * @return mixed + */ private function checkSatisfaction(WebPage $page) { if (true === $this->specification->isSatisfiedBy($page)) { diff --git a/src/Page/Application/Specification/PageIsPublishedSpecification.php b/src/Page/Application/Specification/PageIsPublishedSpecification.php new file mode 100644 index 0000000..6e29c61 --- /dev/null +++ b/src/Page/Application/Specification/PageIsPublishedSpecification.php @@ -0,0 +1,21 @@ +isPublished(); + } +} diff --git a/src/Black/Component/Page/Domain/Event/WebPageCreatedEvent.php b/src/Page/Domain/Event/WebPageCreatedEvent.php similarity index 56% rename from src/Black/Component/Page/Domain/Event/WebPageCreatedEvent.php rename to src/Page/Domain/Event/WebPageCreatedEvent.php index 310c4c8..b47d51e 100644 --- a/src/Black/Component/Page/Domain/Event/WebPageCreatedEvent.php +++ b/src/Page/Domain/Event/WebPageCreatedEvent.php @@ -1,22 +1,11 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -namespace Black\Component\Page\Domain\Event; +namespace Black\Page\Domain\Event; use Symfony\Component\EventDispatcher\Event; /** * Class WebPageCreatedEvent - * - * @author Alexandre 'pocky' Balmes - * @license http://opensource.org/licenses/mit-license.php MIT */ final class WebPageCreatedEvent extends Event { @@ -37,7 +26,7 @@ final class WebPageCreatedEvent extends Event public function __construct($webPageId, $name) { $this->webPageId = $webPageId; - $this->name = $name; + $this->name = $name; } /** diff --git a/src/Black/Component/Page/Domain/Event/WebPageDepublishedEvent.php b/src/Page/Domain/Event/WebPageDepublishedEvent.php similarity index 57% rename from src/Black/Component/Page/Domain/Event/WebPageDepublishedEvent.php rename to src/Page/Domain/Event/WebPageDepublishedEvent.php index d8d0133..040ce02 100644 --- a/src/Black/Component/Page/Domain/Event/WebPageDepublishedEvent.php +++ b/src/Page/Domain/Event/WebPageDepublishedEvent.php @@ -1,22 +1,11 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -namespace Black\Component\Page\Domain\Event; +namespace Black\Page\Domain\Event; use Symfony\Component\EventDispatcher\Event; /** * Class WebPageDepublishedEvent - * - * @author Alexandre 'pocky' Balmes - * @license http://opensource.org/licenses/mit-license.php MIT */ final class WebPageDepublishedEvent extends Event { @@ -37,7 +26,7 @@ final class WebPageDepublishedEvent extends Event public function __construct($webPageId, $name) { $this->webPageId = $webPageId; - $this->name = $name; + $this->name = $name; } /** diff --git a/src/Black/Component/Page/Domain/Event/WebPagePublishedEvent.php b/src/Page/Domain/Event/WebPagePublishedEvent.php similarity index 57% rename from src/Black/Component/Page/Domain/Event/WebPagePublishedEvent.php rename to src/Page/Domain/Event/WebPagePublishedEvent.php index 711add3..0788f4e 100644 --- a/src/Black/Component/Page/Domain/Event/WebPagePublishedEvent.php +++ b/src/Page/Domain/Event/WebPagePublishedEvent.php @@ -1,22 +1,11 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -namespace Black\Component\Page\Domain\Event; +namespace Black\Page\Domain\Event; use Symfony\Component\EventDispatcher\Event; /** * Class WebPagePublishedEvent - * - * @author Alexandre 'pocky' Balmes - * @license http://opensource.org/licenses/mit-license.php MIT */ final class WebPagePublishedEvent extends Event { @@ -37,7 +26,7 @@ final class WebPagePublishedEvent extends Event public function __construct($webPageId, $name) { $this->webPageId = $webPageId; - $this->name = $name; + $this->name = $name; } /** diff --git a/src/Black/Component/Page/Domain/Event/WebPageRemovedEvent.php b/src/Page/Domain/Event/WebPageRemovedEvent.php similarity index 56% rename from src/Black/Component/Page/Domain/Event/WebPageRemovedEvent.php rename to src/Page/Domain/Event/WebPageRemovedEvent.php index ef2b3d1..53ede35 100644 --- a/src/Black/Component/Page/Domain/Event/WebPageRemovedEvent.php +++ b/src/Page/Domain/Event/WebPageRemovedEvent.php @@ -1,22 +1,11 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -namespace Black\Component\Page\Domain\Event; +namespace Black\Page\Domain\Event; use Symfony\Component\EventDispatcher\Event; /** * Class WebPageRemovedEvent - * - * @author Alexandre 'pocky' Balmes - * @license http://opensource.org/licenses/mit-license.php MIT */ final class WebPageRemovedEvent extends Event { @@ -37,7 +26,7 @@ final class WebPageRemovedEvent extends Event public function __construct($webPageId, $name) { $this->webPageId = $webPageId; - $this->name = $name; + $this->name = $name; } /** diff --git a/src/Black/Component/Page/Domain/Event/WebPageWritedEvent.php b/src/Page/Domain/Event/WebPageWritedEvent.php similarity index 56% rename from src/Black/Component/Page/Domain/Event/WebPageWritedEvent.php rename to src/Page/Domain/Event/WebPageWritedEvent.php index 4ddec18..a0e3f65 100644 --- a/src/Black/Component/Page/Domain/Event/WebPageWritedEvent.php +++ b/src/Page/Domain/Event/WebPageWritedEvent.php @@ -1,22 +1,11 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -namespace Black\Component\Page\Domain\Event; +namespace Black\Page\Domain\Event; use Symfony\Component\EventDispatcher\Event; /** * Class WebPageWritedEvent - * - * @author Alexandre 'pocky' Balmes - * @license http://opensource.org/licenses/mit-license.php MIT */ final class WebPageWritedEvent extends Event { @@ -37,7 +26,7 @@ final class WebPageWritedEvent extends Event public function __construct($webPageId, $name) { $this->webPageId = $webPageId; - $this->name = $name; + $this->name = $name; } /** diff --git a/src/Black/Component/Page/Domain/Exception/WebPageNotFoundException.php b/src/Page/Domain/Exception/WebPageNotFoundException.php similarity index 58% rename from src/Black/Component/Page/Domain/Exception/WebPageNotFoundException.php rename to src/Page/Domain/Exception/WebPageNotFoundException.php index 2b2316e..fb77f7f 100644 --- a/src/Black/Component/Page/Domain/Exception/WebPageNotFoundException.php +++ b/src/Page/Domain/Exception/WebPageNotFoundException.php @@ -1,23 +1,11 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Black\Component\Page\Domain\Exception; +namespace Black\Page\Domain\Exception; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; /** * Class WebPageNotFoundException - * - * @author Alexandre 'pocky' Balmes - * @license http://opensource.org/licenses/mit-license.php MIT */ final class WebPageNotFoundException extends NotFoundHttpException { diff --git a/src/Black/Component/Page/Domain/Listener/LoggerListener.php b/src/Page/Domain/Listener/LoggerListener.php similarity index 62% rename from src/Black/Component/Page/Domain/Listener/LoggerListener.php rename to src/Page/Domain/Listener/LoggerListener.php index 327c8ae..6b93463 100644 --- a/src/Black/Component/Page/Domain/Listener/LoggerListener.php +++ b/src/Page/Domain/Listener/LoggerListener.php @@ -1,8 +1,8 @@ 'addInfoLog', - WebPageDomainEvents::WEBPAGE_DOMAIN_DEPUBLISHED => 'addInfoLog', - WebPageDomainEvents::WEBPAGE_DOMAIN_PUBLISHED => 'addInfoLog', - WebPageDomainEvents::WEBPAGE_DOMAIN_REMOVED => 'addInfoLog', - WebPageDomainEvents::WEBPAGE_DOMAIN_WRITE => 'addInfoLog', + WebPageEvents::WEBPAGE_DOMAIN_CREATED => 'addInfoLog', + WebPageEvents::WEBPAGE_DOMAIN_DEPUBLISHED => 'addInfoLog', + WebPageEvents::WEBPAGE_DOMAIN_PUBLISHED => 'addInfoLog', + WebPageEvents::WEBPAGE_DOMAIN_REMOVED => 'addInfoLog', + WebPageEvents::WEBPAGE_DOMAIN_WRITE => 'addInfoLog', ]; } diff --git a/src/Black/Component/Page/Domain/Model/WebPage.php b/src/Page/Domain/Model/WebPage.php similarity index 75% rename from src/Black/Component/Page/Domain/Model/WebPage.php rename to src/Page/Domain/Model/WebPage.php index 6f9533b..d49cba1 100644 --- a/src/Black/Component/Page/Domain/Model/WebPage.php +++ b/src/Page/Domain/Model/WebPage.php @@ -1,23 +1,9 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Black\Component\Page\Domain\Model; +namespace Black\Page\Domain\Model; /** * Class WebPage - * - * A web page. Every web page is implicitly assumed to be declared to be of type WebPage. - * - * @author Alexandre 'pocky' Balmes - * @license http://opensource.org/licenses/mit-license.php MIT */ class WebPage { @@ -84,11 +70,11 @@ class WebPage */ public function __construct(WebPageId $id, $author, $name, $slug) { - $this->webPageId = $id; - $this->name = $name; - $this->slug = $slug; - $this->author = $author; - $this->dateCreated = new \DateTime(); + $this->webPageId = $id; + $this->name = $name; + $this->slug = $slug; + $this->author = $author; + $this->dateCreated = new \DateTime(); $this->dateModified = new \DateTime(); } @@ -187,9 +173,9 @@ public function isPublished() */ public function write($headline, $about, $text) { - $this->headline = $headline; - $this->about = $about; - $this->text = $text; + $this->headline = $headline; + $this->about = $about; + $this->text = $text; $this->dateModified = new \DateTime(); } @@ -217,10 +203,10 @@ public function depublish() */ public function edit($name, $headline, $about, $text) { - $this->name = $name; - $this->headline = $headline; - $this->about = $about; - $this->text = $text; + $this->name = $name; + $this->headline = $headline; + $this->about = $about; + $this->text = $text; $this->dateModified = new \DateTime(); } } diff --git a/src/Black/Component/Page/Domain/Model/WebPageId.php b/src/Page/Domain/Model/WebPageId.php similarity index 62% rename from src/Black/Component/Page/Domain/Model/WebPageId.php rename to src/Page/Domain/Model/WebPageId.php index 3b70840..c36de53 100644 --- a/src/Black/Component/Page/Domain/Model/WebPageId.php +++ b/src/Page/Domain/Model/WebPageId.php @@ -1,20 +1,9 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -namespace Black\Component\Page\Domain\Model; +namespace Black\Page\Domain\Model; /** * Class WebPageId - * - * @author Alexandre 'pocky' Balmes - * @license http://opensource.org/licenses/mit-license.php MIT */ final class WebPageId { diff --git a/src/Page/Domain/Model/WebPageReadRepository.php b/src/Page/Domain/Model/WebPageReadRepository.php new file mode 100644 index 0000000..62b1177 --- /dev/null +++ b/src/Page/Domain/Model/WebPageReadRepository.php @@ -0,0 +1,15 @@ + - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -namespace Black\Component\Page\Infrastructure\CQRS\Command; +namespace Black\Page\Infrastructure\CQRS\Command; -use Black\Component\Page\Domain\Model\WebPageId; +use Black\Page\Domain\Model\WebPageId; use Black\DDD\CQRSinPHP\Infrastructure\CQRS\Command; /** * Class CreateWebPageCommand - * - * @author Alexandre 'pocky' Balmes - * @license http://opensource.org/licenses/mit-license.php MIT */ final class CreateWebPageCommand implements Command { /** - * @var \Black\Component\Page\Domain\Model\WebPageId + * @var \Black\Page\Domain\Model\WebPageId */ private $webPageId; @@ -44,8 +33,8 @@ final class CreateWebPageCommand implements Command public function __construct(WebPageId $webPageId, $author, $name) { $this->webPageId = $webPageId; - $this->author = $author; - $this->name = $name; + $this->author = $author; + $this->name = $name; } /** diff --git a/src/Black/Component/Page/Infrastructure/CQRS/Command/DepublishWebPageCommand.php b/src/Page/Infrastructure/CQRS/Command/DepublishWebPageCommand.php similarity index 50% rename from src/Black/Component/Page/Infrastructure/CQRS/Command/DepublishWebPageCommand.php rename to src/Page/Infrastructure/CQRS/Command/DepublishWebPageCommand.php index d704879..40306d1 100644 --- a/src/Black/Component/Page/Infrastructure/CQRS/Command/DepublishWebPageCommand.php +++ b/src/Page/Infrastructure/CQRS/Command/DepublishWebPageCommand.php @@ -1,23 +1,12 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -namespace Black\Component\Page\Infrastructure\CQRS\Command; +namespace Black\Page\Infrastructure\CQRS\Command; -use Black\Component\Page\Domain\Model\WebPage; +use Black\Page\Domain\Model\WebPage; use Black\DDD\CQRSinPHP\Infrastructure\CQRS\Command; /** * Class DepublishWebPageCommand - * - * @author Alexandre 'pocky' Balmes - * @license http://opensource.org/licenses/mit-license.php MIT */ final class DepublishWebPageCommand implements Command { diff --git a/src/Black/Component/Page/Infrastructure/CQRS/Command/PublishWebPageCommand.php b/src/Page/Infrastructure/CQRS/Command/PublishWebPageCommand.php similarity index 50% rename from src/Black/Component/Page/Infrastructure/CQRS/Command/PublishWebPageCommand.php rename to src/Page/Infrastructure/CQRS/Command/PublishWebPageCommand.php index bd6b0b2..ddef3ef 100644 --- a/src/Black/Component/Page/Infrastructure/CQRS/Command/PublishWebPageCommand.php +++ b/src/Page/Infrastructure/CQRS/Command/PublishWebPageCommand.php @@ -1,23 +1,12 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -namespace Black\Component\Page\Infrastructure\CQRS\Command; +namespace Black\Page\Infrastructure\CQRS\Command; -use Black\Component\Page\Domain\Model\WebPage; +use Black\Page\Domain\Model\WebPage; use Black\DDD\CQRSinPHP\Infrastructure\CQRS\Command; /** * Class PublishWebPageCommand - * - * @author Alexandre 'pocky' Balmes - * @license http://opensource.org/licenses/mit-license.php MIT */ final class PublishWebPageCommand implements Command { diff --git a/src/Page/Infrastructure/CQRS/Command/RemoveWebPageCommand.php b/src/Page/Infrastructure/CQRS/Command/RemoveWebPageCommand.php new file mode 100644 index 0000000..84bfb39 --- /dev/null +++ b/src/Page/Infrastructure/CQRS/Command/RemoveWebPageCommand.php @@ -0,0 +1,33 @@ +webPage = $webPage; + } + + /** + * @return mixed + */ + public function getWebPage() + { + return $this->webPage; + } +} diff --git a/src/Black/Component/Page/Infrastructure/CQRS/Command/WriteWebPageCommand.php b/src/Page/Infrastructure/CQRS/Command/WriteWebPageCommand.php similarity index 69% rename from src/Black/Component/Page/Infrastructure/CQRS/Command/WriteWebPageCommand.php rename to src/Page/Infrastructure/CQRS/Command/WriteWebPageCommand.php index bedbaca..e137f70 100644 --- a/src/Black/Component/Page/Infrastructure/CQRS/Command/WriteWebPageCommand.php +++ b/src/Page/Infrastructure/CQRS/Command/WriteWebPageCommand.php @@ -1,28 +1,17 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -namespace Black\Component\Page\Infrastructure\CQRS\Command; +namespace Black\Page\Infrastructure\CQRS\Command; -use Black\Component\Page\Domain\Model\WebPageId; +use Black\Page\Domain\Model\WebPageId; use Black\DDD\CQRSinPHP\Infrastructure\CQRS\Command; /** * Class WriteWebPageCommand - * - * @author Alexandre 'pocky' Balmes - * @license http://opensource.org/licenses/mit-license.php MIT */ final class WriteWebPageCommand implements Command { /** - * @var \Black\Component\Page\Domain\Model\WebPage + * @var \Black\Page\Domain\Model\WebPage */ private $webPageId; diff --git a/src/Black/Component/Page/Infrastructure/CQRS/Handler/CreateWebPageHandler.php b/src/Page/Infrastructure/CQRS/Handler/CreateWebPageHandler.php similarity index 52% rename from src/Black/Component/Page/Infrastructure/CQRS/Handler/CreateWebPageHandler.php rename to src/Page/Infrastructure/CQRS/Handler/CreateWebPageHandler.php index 449d943..7152ce6 100644 --- a/src/Black/Component/Page/Infrastructure/CQRS/Handler/CreateWebPageHandler.php +++ b/src/Page/Infrastructure/CQRS/Handler/CreateWebPageHandler.php @@ -1,28 +1,17 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -namespace Black\Component\Page\Infrastructure\CQRS\Handler; +namespace Black\Page\Infrastructure\CQRS\Handler; -use Black\Component\Page\Domain\Model\WebPageWriteRepository; -use Black\Component\Page\Infrastructure\CQRS\Command\CreateWebPageCommand; -use Black\Component\Page\Domain\Event\WebPageCreatedEvent; -use Black\Component\Page\Infrastructure\Service\WebPageWriteService; -use Black\Component\Page\WebPageDomainEvents; +use Black\DDD\CQRSinPHP\Infrastructure\CQRS\Command; +use Black\Page\Domain\Model\WebPageWriteRepository; +use Black\Page\Domain\Event\WebPageCreatedEvent; +use Black\Page\Infrastructure\Service\WebPageWriteService; +use Black\Page\WebPageEvents; use Black\DDD\CQRSinPHP\Infrastructure\CQRS\CommandHandler; use Symfony\Component\EventDispatcher\EventDispatcherInterface; /** * Class CreateWebPageHandler - * - * @author Alexandre 'pocky' Balmes - * @license http://opensource.org/licenses/mit-license.php MIT */ final class CreateWebPageHandler implements CommandHandler { @@ -51,21 +40,20 @@ public function __construct( WebPageWriteRepository $repository, EventDispatcherInterface $eventDispatcher ) { - $this->service = $service; - $this->repository = $repository; + $this->service = $service; + $this->repository = $repository; $this->eventDispatcher = $eventDispatcher; } /** - * @param CreateWebPageCommand $command - * @return mixed + * @param Command $command */ - public function handle(CreateWebPageCommand $command) + public function handle(Command $command) { $page = $this->service->create($command->getWebPageId(), $command->getAuthor(), $command->getName()); $this->repository->flush(); $event = new WebPageCreatedEvent($page->getWebPageId()->getValue(), $page->getName()); - $this->eventDispatcher->dispatch(WebPageDomainEvents::WEBPAGE_DOMAIN_CREATED, $event); + $this->eventDispatcher->dispatch(WebPageEvents::WEBPAGE_DOMAIN_CREATED, $event); } } diff --git a/src/Black/Component/Page/Infrastructure/CQRS/Handler/DepublishWebPageHandler.php b/src/Page/Infrastructure/CQRS/Handler/DepublishWebPageHandler.php similarity index 50% rename from src/Black/Component/Page/Infrastructure/CQRS/Handler/DepublishWebPageHandler.php rename to src/Page/Infrastructure/CQRS/Handler/DepublishWebPageHandler.php index 35ba07f..b7d5584 100644 --- a/src/Black/Component/Page/Infrastructure/CQRS/Handler/DepublishWebPageHandler.php +++ b/src/Page/Infrastructure/CQRS/Handler/DepublishWebPageHandler.php @@ -1,28 +1,17 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -namespace Black\Component\Page\Infrastructure\CQRS\Handler; +namespace Black\Page\Infrastructure\CQRS\Handler; -use Black\Component\Page\Domain\Model\WebPageWriteRepository; -use Black\Component\Page\Infrastructure\CQRS\Command\DepublishWebPageCommand; -use Black\Component\Page\Domain\Event\WebPageDepublishedEvent; -use Black\Component\Page\Infrastructure\Service\WebPageWriteService; -use Black\Component\Page\WebPageDomainEvents; +use Black\DDD\CQRSinPHP\Infrastructure\CQRS\Command; +use Black\Page\Domain\Model\WebPageWriteRepository; +use Black\Page\Domain\Event\WebPageDepublishedEvent; +use Black\Page\Infrastructure\Service\WebPageWriteService; +use Black\Page\WebPageEvents; use Black\DDD\CQRSinPHP\Infrastructure\CQRS\CommandHandler; use Symfony\Component\EventDispatcher\EventDispatcherInterface; /** * Class DepublishWebPageHandler - * - * @author Alexandre 'pocky' Balmes - * @license http://opensource.org/licenses/mit-license.php MIT */ final class DepublishWebPageHandler implements CommandHandler { @@ -51,22 +40,21 @@ public function __construct( WebPageWriteRepository $repository, EventDispatcherInterface $eventDispatcher ) { - $this->service = $service; - $this->repository = $repository; + $this->service = $service; + $this->repository = $repository; $this->eventDispatcher = $eventDispatcher; } /** - * @param DepublishWebPageCommand $command - * @return mixed + * @param Command $command */ - public function handle(DepublishWebPageCommand $command) + public function handle(Command $command) { $page = $this->service->depublish($command->getWebPage()); $this->repository->flush(); $event = new WebPageDepublishedEvent($page->getWebPageId()->getValue(), $page->getName()); - $this->eventDispatcher->dispatch(WebPageDomainEvents::WEBPAGE_DOMAIN_DEPUBLISHED, $event); + $this->eventDispatcher->dispatch(WebPageEvents::WEBPAGE_DOMAIN_DEPUBLISHED, $event); } } diff --git a/src/Page/Infrastructure/CQRS/Handler/PublishWebPageHandler.php b/src/Page/Infrastructure/CQRS/Handler/PublishWebPageHandler.php new file mode 100644 index 0000000..1ce73d3 --- /dev/null +++ b/src/Page/Infrastructure/CQRS/Handler/PublishWebPageHandler.php @@ -0,0 +1,62 @@ +service = $service; + $this->repository = $repository; + $this->eventDispatcher = $eventDispatcher; + } + + /** + * @param Command $command + */ + public function handle(Command $command) + { + $page = $this->service->publish($command->getWebPage()); + + $this->repository->flush(); + + $event = new WebPagePublishedEvent($page->getWebPageId()->getValue(), $page->getName()); + $this->eventDispatcher->dispatch(WebPageEvents::WEBPAGE_DOMAIN_PUBLISHED, $event); + } +} diff --git a/src/Black/Component/Page/Infrastructure/CQRS/Handler/RemoveWebPageHandler.php b/src/Page/Infrastructure/CQRS/Handler/RemoveWebPageHandler.php similarity index 51% rename from src/Black/Component/Page/Infrastructure/CQRS/Handler/RemoveWebPageHandler.php rename to src/Page/Infrastructure/CQRS/Handler/RemoveWebPageHandler.php index 1e1059f..748c43f 100644 --- a/src/Black/Component/Page/Infrastructure/CQRS/Handler/RemoveWebPageHandler.php +++ b/src/Page/Infrastructure/CQRS/Handler/RemoveWebPageHandler.php @@ -1,28 +1,17 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -namespace Black\Component\Page\Infrastructure\CQRS\Handler; +namespace Black\Page\Infrastructure\CQRS\Handler; -use Black\Component\Page\Domain\Model\WebPageWriteRepository; -use Black\Component\Page\Infrastructure\CQRS\Command\RemoveWebPageCommand; -use Black\Component\Page\Domain\Event\WebPageRemovedEvent; -use Black\Component\Page\Infrastructure\Service\WebPageWriteService; -use Black\Component\Page\WebPageDomainEvents; +use Black\DDD\CQRSinPHP\Infrastructure\CQRS\Command; +use Black\Page\Domain\Model\WebPageWriteRepository; +use Black\Page\Domain\Event\WebPageRemovedEvent; +use Black\Page\Infrastructure\Service\WebPageWriteService; +use Black\Page\WebPageEvents; use Black\DDD\CQRSinPHP\Infrastructure\CQRS\CommandHandler; use Symfony\Component\EventDispatcher\EventDispatcherInterface; /** * Class RemoveWebPageHandler - * - * @author Alexandre 'pocky' Balmes - * @license http://opensource.org/licenses/mit-license.php MIT */ final class RemoveWebPageHandler implements CommandHandler { @@ -51,22 +40,21 @@ public function __construct( WebPageWriteRepository $repository, EventDispatcherInterface $eventDispatcher ) { - $this->service = $service; - $this->repository = $repository; + $this->service = $service; + $this->repository = $repository; $this->eventDispatcher = $eventDispatcher; } /** - * @param RemoveWebPageCommand $command - * @return mixed + * @param Command $command */ - public function handle(RemoveWebPageCommand $command) + public function handle(Command $command) { $page = $this->service->remove($command->getWebPage()); $this->repository->flush(); $event = new WebPageRemovedEvent($page->getWebPageId()->getValue(), $page->getName()); - $this->eventDispatcher->dispatch(WebPageDomainEvents::WEBPAGE_DOMAIN_REMOVED, $event); + $this->eventDispatcher->dispatch(WebPageEvents::WEBPAGE_DOMAIN_REMOVED, $event); } } diff --git a/src/Black/Component/Page/Infrastructure/CQRS/Handler/WriteWebPageHandler.php b/src/Page/Infrastructure/CQRS/Handler/WriteWebPageHandler.php similarity index 58% rename from src/Black/Component/Page/Infrastructure/CQRS/Handler/WriteWebPageHandler.php rename to src/Page/Infrastructure/CQRS/Handler/WriteWebPageHandler.php index 871ba5b..4b7024e 100644 --- a/src/Black/Component/Page/Infrastructure/CQRS/Handler/WriteWebPageHandler.php +++ b/src/Page/Infrastructure/CQRS/Handler/WriteWebPageHandler.php @@ -1,30 +1,19 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -namespace Black\Component\Page\Infrastructure\CQRS\Handler; +namespace Black\Page\Infrastructure\CQRS\Handler; -use Black\Component\Page\Domain\Model\WebPageId; -use Black\Component\Page\Domain\Model\WebPageWriteRepository; -use Black\Component\Page\Infrastructure\CQRS\Command\WriteWebPageCommand; -use Black\Component\Page\Domain\Event\WebPageWritedEvent; -use Black\Component\Page\Infrastructure\Service\WebPageReadService; -use Black\Component\Page\Infrastructure\Service\WebPageWriteService; -use Black\Component\Page\WebPageDomainEvents; +use Black\DDD\CQRSinPHP\Infrastructure\CQRS\Command; +use Black\Page\Domain\Model\WebPageId; +use Black\Page\Domain\Model\WebPageWriteRepository; +use Black\Page\Domain\Event\WebPageWritedEvent; +use Black\Page\Infrastructure\Service\WebPageReadService; +use Black\Page\Infrastructure\Service\WebPageWriteService; +use Black\Page\WebPageEvents; use Black\DDD\CQRSinPHP\Infrastructure\CQRS\CommandHandler; use Symfony\Component\EventDispatcher\EventDispatcherInterface; /** * Class WriteWebPageHandler - * - * @author Alexandre 'pocky' Balmes - * @license http://opensource.org/licenses/mit-license.php MIT */ final class WriteWebPageHandler implements CommandHandler { @@ -63,15 +52,14 @@ public function __construct( ) { $this->readService = $readService; $this->writeService = $writeService; - $this->repository = $repository; + $this->repository = $repository; $this->eventDispatcher = $eventDispatcher; } /** - * @param WriteWebPageCommand $command - * @return mixed + * @param Command $command */ - public function handle(WriteWebPageCommand $command) + public function handle(Command $command) { $page = $this->readService->read($command->getWebPageId()); $page = $this->writeService->write( @@ -84,6 +72,6 @@ public function handle(WriteWebPageCommand $command) $this->repository->flush(); $event = new WebPageWritedEvent($page->getWebPageId()->getValue(), $page->getName()); - $this->eventDispatcher->dispatch(WebPageDomainEvents::WEBPAGE_DOMAIN_WRITE, $event); + $this->eventDispatcher->dispatch(WebPageEvents::WEBPAGE_DOMAIN_WRITE, $event); } } diff --git a/src/Black/Component/Page/Infrastructure/Listener/WebPageCreatedListener.php b/src/Page/Infrastructure/Listener/WebPageCreatedListener.php similarity index 61% rename from src/Black/Component/Page/Infrastructure/Listener/WebPageCreatedListener.php rename to src/Page/Infrastructure/Listener/WebPageCreatedListener.php index da06f4d..d9bec82 100644 --- a/src/Black/Component/Page/Infrastructure/Listener/WebPageCreatedListener.php +++ b/src/Page/Infrastructure/Listener/WebPageCreatedListener.php @@ -1,24 +1,13 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -namespace Black\Component\Page\Infrastructure\Listener; +namespace Black\Page\Infrastructure\Listener; -use Black\Component\Page\Domain\Event\WebPageCreatedEvent; +use Black\Page\Domain\Event\WebPageCreatedEvent; use Monolog\Logger; use Symfony\Component\EventDispatcher\EventSubscriberInterface; /** * Class WebPageCreatedListener - * - * @author Alexandre 'pocky' Balmes - * @license http://opensource.org/licenses/mit-license.php MIT */ class WebPageCreatedListener implements EventSubscriberInterface { diff --git a/src/Black/Component/Page/Infrastructure/Listener/WebPageDepublishedListener.php b/src/Page/Infrastructure/Listener/WebPageDepublishedListener.php similarity index 61% rename from src/Black/Component/Page/Infrastructure/Listener/WebPageDepublishedListener.php rename to src/Page/Infrastructure/Listener/WebPageDepublishedListener.php index 5de0488..a988902 100644 --- a/src/Black/Component/Page/Infrastructure/Listener/WebPageDepublishedListener.php +++ b/src/Page/Infrastructure/Listener/WebPageDepublishedListener.php @@ -1,24 +1,13 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -namespace Black\Component\Page\Infrastructure\Listener; +namespace Black\Page\Infrastructure\Listener; -use Black\Component\Page\Domain\Event\WebPageDepublishedEvent; +use Black\Page\Domain\Event\WebPageDepublishedEvent; use Monolog\Logger; use Symfony\Component\EventDispatcher\EventSubscriberInterface; /** * Class WebPageDepublishedListener - * - * @author Alexandre 'pocky' Balmes - * @license http://opensource.org/licenses/mit-license.php MIT */ class WebPageDepublishedListener implements EventSubscriberInterface { diff --git a/src/Black/Component/Page/Infrastructure/Listener/WebPagePublishedListener.php b/src/Page/Infrastructure/Listener/WebPagePublishedListener.php similarity index 60% rename from src/Black/Component/Page/Infrastructure/Listener/WebPagePublishedListener.php rename to src/Page/Infrastructure/Listener/WebPagePublishedListener.php index 95badf5..85a992f 100644 --- a/src/Black/Component/Page/Infrastructure/Listener/WebPagePublishedListener.php +++ b/src/Page/Infrastructure/Listener/WebPagePublishedListener.php @@ -1,24 +1,13 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -namespace Black\Component\Page\Infrastructure\Listener; +namespace Black\Page\Infrastructure\Listener; -use Black\Component\Page\Domain\Event\WebPagePublishedEvent; +use Black\Page\Domain\Event\WebPagePublishedEvent; use Monolog\Logger; use Symfony\Component\EventDispatcher\EventSubscriberInterface; /** * Class WebPagePublishedListener - * - * @author Alexandre 'pocky' Balmes - * @license http://opensource.org/licenses/mit-license.php MIT */ class WebPagePublishedListener implements EventSubscriberInterface { diff --git a/src/Black/Component/Page/Infrastructure/Listener/WebPageRemovedListener.php b/src/Page/Infrastructure/Listener/WebPageRemovedListener.php similarity index 60% rename from src/Black/Component/Page/Infrastructure/Listener/WebPageRemovedListener.php rename to src/Page/Infrastructure/Listener/WebPageRemovedListener.php index e596c59..89f2e70 100644 --- a/src/Black/Component/Page/Infrastructure/Listener/WebPageRemovedListener.php +++ b/src/Page/Infrastructure/Listener/WebPageRemovedListener.php @@ -1,24 +1,13 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -namespace Black\Component\Page\Infrastructure\Listener; +namespace Black\Page\Infrastructure\Listener; -use Black\Component\Page\Domain\Event\WebPageRemovedEvent; +use Black\Page\Domain\Event\WebPageRemovedEvent; use Monolog\Logger; use Symfony\Component\EventDispatcher\EventSubscriberInterface; /** * Class WebPageRemovedListener - * - * @author Alexandre 'pocky' Balmes - * @license http://opensource.org/licenses/mit-license.php MIT */ class WebPageRemovedListener implements EventSubscriberInterface { diff --git a/src/Black/Component/Page/Infrastructure/Listener/WebPageWritedListener.php b/src/Page/Infrastructure/Listener/WebPageWritedListener.php similarity index 60% rename from src/Black/Component/Page/Infrastructure/Listener/WebPageWritedListener.php rename to src/Page/Infrastructure/Listener/WebPageWritedListener.php index 1371a6b..00e5f42 100644 --- a/src/Black/Component/Page/Infrastructure/Listener/WebPageWritedListener.php +++ b/src/Page/Infrastructure/Listener/WebPageWritedListener.php @@ -1,24 +1,13 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -namespace Black\Component\Page\Infrastructure\Listener; +namespace Black\Page\Infrastructure\Listener; -use Black\Component\Page\Domain\Event\WebPageWritedEvent; +use Black\Page\Domain\Event\WebPageWritedEvent; use Monolog\Logger; use Symfony\Component\EventDispatcher\EventSubscriberInterface; /** * Class WebPageWritedListener - * - * @author Alexandre 'pocky' Balmes - * @license http://opensource.org/licenses/mit-license.php MIT */ class WebPageWritedListener implements EventSubscriberInterface { diff --git a/src/Black/Component/Page/Infrastructure/Persistence/MongoDB/ReadRepository.php b/src/Page/Infrastructure/Persistence/MongoDB/ReadRepository.php similarity index 87% rename from src/Black/Component/Page/Infrastructure/Persistence/MongoDB/ReadRepository.php rename to src/Page/Infrastructure/Persistence/MongoDB/ReadRepository.php index de1eeef..a582594 100644 --- a/src/Black/Component/Page/Infrastructure/Persistence/MongoDB/ReadRepository.php +++ b/src/Page/Infrastructure/Persistence/MongoDB/ReadRepository.php @@ -1,10 +1,10 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -namespace Black\Component\Page\Infrastructure\Service; +namespace Black\Page\Infrastructure\Service; -use Black\Component\Page\Domain\Exception\WebPageNotFoundException; -use Black\Component\Page\Domain\Model\WebPageId; -use Black\Component\Page\Domain\Model\WebPageReadRepository; +use Black\Page\Domain\Exception\WebPageNotFoundException; +use Black\Page\Domain\Model\WebPageId; +use Black\Page\Domain\Model\WebPageReadRepository; class WebPageReadService { diff --git a/src/Black/Component/Page/Infrastructure/Service/WebPageWriteService.php b/src/Page/Infrastructure/Service/WebPageWriteService.php similarity index 81% rename from src/Black/Component/Page/Infrastructure/Service/WebPageWriteService.php rename to src/Page/Infrastructure/Service/WebPageWriteService.php index f3867ba..253b5a3 100644 --- a/src/Black/Component/Page/Infrastructure/Service/WebPageWriteService.php +++ b/src/Page/Infrastructure/Service/WebPageWriteService.php @@ -1,18 +1,10 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Black\Component\Page\Infrastructure\Service; - -use Black\Component\Page\Domain\Model\WebPage; -use Black\Component\Page\Domain\Model\WebPageId; -use Black\Component\Page\Domain\Model\WebPageWriteRepository; + +namespace Black\Page\Infrastructure\Service; + +use Black\Page\Domain\Model\WebPage; +use Black\Page\Domain\Model\WebPageId; +use Black\Page\Domain\Model\WebPageWriteRepository; use Cocur\Slugify\Slugify; class WebPageWriteService From f6b6624f30c87b2323ed2ed9c988b36ff29ef07a Mon Sep 17 00:00:00 2001 From: Alexandre 'pocky' Balmes Date: Sat, 20 Feb 2016 23:29:47 +0100 Subject: [PATCH 2/5] Copy BlackPageBundle in Infrastructure --- .../Command/CreateWebPageCommand.php | 120 +++++++++++++ .../Command/DepublishWebPageCommand.php | 106 ++++++++++++ .../Command/PublishWebPageCommand.php | 106 ++++++++++++ .../Command/RemoveWebPageCommand.php | 106 ++++++++++++ .../Command/WriteWebPageCommand.php | 162 ++++++++++++++++++ .../BlackPageExtension.php | 114 ++++++++++++ .../DependencyInjection/Configuration.php | 52 ++++++ .../Form/Handler/CreateWebPageFormHandler.php | 21 +++ .../Form/Handler/WriteWebPageFormHandler.php | 21 +++ .../Form/Type/CreateWebPageType.php | 81 +++++++++ .../Form/Type/WriteWebPageType.php | 90 ++++++++++ .../Symfony/PageBundle/BlackPageBundle.php | 67 ++++++++ .../Listener/FlashNoticeListener.php | 81 +++++++++ .../Resources/config/application_service.xml | 20 +++ .../PageBundle/Resources/config/command.xml | 57 ++++++ .../Resources/config/controller.xml | 48 ++++++ .../PageBundle/Resources/config/cqrs.xml | 54 ++++++ .../config/doctrine/model/WebPage.mongodb.xml | 34 ++++ .../config/doctrine/model/WebPage.orm.xml | 34 ++++ .../doctrine/model/WebPageId.mongodb.xml | 12 ++ .../config/doctrine/model/WebPageId.orm.xml | 12 ++ .../Resources/config/domain_event.xml | 28 +++ .../PageBundle/Resources/config/dto.xml | 37 ++++ .../PageBundle/Resources/config/form.xml | 69 ++++++++ .../config/infrastructure_service.xml | 23 +++ .../PageBundle/Resources/config/mongodb.xml | 36 ++++ .../PageBundle/Resources/config/orm.xml | 36 ++++ .../Resources/config/specification.xml | 16 ++ .../Resources/config/validation.xml | 143 ++++++++++++++++ .../Resources/translations/dto.en.yml | 37 ++++ .../Resources/translations/dto.fr.yml | 36 ++++ .../Resources/translations/flash.en.yml | 5 + .../Resources/translations/flash.fr.yml | 5 + .../Resources/translations/form.en.yml | 17 ++ .../Resources/translations/form.fr.yml | 17 ++ 35 files changed, 1903 insertions(+) create mode 100644 src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Command/CreateWebPageCommand.php create mode 100644 src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Command/DepublishWebPageCommand.php create mode 100644 src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Command/PublishWebPageCommand.php create mode 100644 src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Command/RemoveWebPageCommand.php create mode 100644 src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Command/WriteWebPageCommand.php create mode 100644 src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/DependencyInjection/BlackPageExtension.php create mode 100644 src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/DependencyInjection/Configuration.php create mode 100644 src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Form/Handler/CreateWebPageFormHandler.php create mode 100644 src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Form/Handler/WriteWebPageFormHandler.php create mode 100644 src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Form/Type/CreateWebPageType.php create mode 100644 src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Form/Type/WriteWebPageType.php create mode 100644 src/Page/Infrastructure/Bridge/Symfony/PageBundle/BlackPageBundle.php create mode 100644 src/Page/Infrastructure/Bridge/Symfony/PageBundle/Infrastructure/Listener/FlashNoticeListener.php create mode 100644 src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/application_service.xml create mode 100644 src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/command.xml create mode 100644 src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/controller.xml create mode 100644 src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/cqrs.xml create mode 100644 src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/doctrine/model/WebPage.mongodb.xml create mode 100644 src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/doctrine/model/WebPage.orm.xml create mode 100644 src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/doctrine/model/WebPageId.mongodb.xml create mode 100644 src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/doctrine/model/WebPageId.orm.xml create mode 100644 src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/domain_event.xml create mode 100644 src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/dto.xml create mode 100644 src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/form.xml create mode 100644 src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/infrastructure_service.xml create mode 100644 src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/mongodb.xml create mode 100644 src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/orm.xml create mode 100644 src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/specification.xml create mode 100644 src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/validation.xml create mode 100644 src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/translations/dto.en.yml create mode 100644 src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/translations/dto.fr.yml create mode 100644 src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/translations/flash.en.yml create mode 100644 src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/translations/flash.fr.yml create mode 100644 src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/translations/form.en.yml create mode 100644 src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/translations/form.fr.yml diff --git a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Command/CreateWebPageCommand.php b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Command/CreateWebPageCommand.php new file mode 100644 index 0000000..14cb896 --- /dev/null +++ b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Command/CreateWebPageCommand.php @@ -0,0 +1,120 @@ +bus = $bus; + $this->handler = $handler; + $this->commandName = $commandName; + + parent::__construct(); + } + + /** + * + */ + protected function configure() + { + $this + ->setName('black:page:create') + ->setDescription('Create a new page') + ->addArgument('author', InputArgument::OPTIONAL, 'The author') + ->addArgument('name', InputArgument::OPTIONAL, 'The page name'); + } + + /** + * @param InputInterface $input + * @param OutputInterface $output + */ + protected function interact(InputInterface $input, OutputInterface $output) + { + $dialog = $this->getHelperSet()->get('dialog'); + + if (!$input->getArgument('author')) { + $author = $dialog->askAndValidate( + $output, + 'Please give an author name:', + function ($author) { + if (empty($author)) { + throw new \InvalidArgumentException('Author cannot be empty!'); + } + + return $author; + } + ); + + $input->setArgument('author', $author); + } + + if (!$input->getArgument('name')) { + $name = $dialog->askAndValidate( + $output, + 'Please choose a name:', + function ($name) { + if (empty($name)) { + throw new \InvalidArgumentException('Name cannot be empty!'); + } + + return $name; + } + ); + + $input->setArgument('name', $name); + } + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $pageId = new WebPageId(Uuid::uuid4()); + + $this->bus->register($this->commandName, $this->handler); + $this->bus->handle(new $this->commandName( + $pageId, + $input->getArgument('author'), + $input->getArgument('name') + )); + } +} diff --git a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Command/DepublishWebPageCommand.php b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Command/DepublishWebPageCommand.php new file mode 100644 index 0000000..f8c3b1b --- /dev/null +++ b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Command/DepublishWebPageCommand.php @@ -0,0 +1,106 @@ +bus = $bus; + $this->handler = $handler; + $this->service = $service; + $this->commandName = $commandName; + + parent::__construct(); + } + + /** + * + */ + protected function configure() + { + $this + ->setName('black:page:depublish') + ->setDescription('Publish a new page') + ->addArgument('id', InputArgument::OPTIONAL, 'The page identifier') + ; + } + + /** + * @param InputInterface $input + * @param OutputInterface $output + */ + protected function interact(InputInterface $input, OutputInterface $output) + { + $dialog = $this->getHelperSet()->get('dialog'); + + if (!$input->getArgument('id')) { + $id = $dialog->askAndValidate( + $output, + 'Please give an id:', + function ($id) { + if (empty($id)) { + throw new \InvalidArgumentException('Id cannot be empty!'); + } + + return $id; + } + ); + + $input->setArgument('id', $id); + } + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $pageId = new WebPageId($input->getArgument('id')); + $page = $this->service->read($pageId); + + if ($page) { + $this->bus->register($this->commandName, $this->handler); + $this->bus->handle(new $this->commandName($page)); + } + } +} diff --git a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Command/PublishWebPageCommand.php b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Command/PublishWebPageCommand.php new file mode 100644 index 0000000..519676b --- /dev/null +++ b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Command/PublishWebPageCommand.php @@ -0,0 +1,106 @@ +bus = $bus; + $this->handler = $handler; + $this->service = $service; + $this->commandName = $commandName; + + parent::__construct(); + } + + /** + * + */ + protected function configure() + { + $this + ->setName('black:page:publish') + ->setDescription('Publish a new page') + ->addArgument('id', InputArgument::OPTIONAL, 'The page identifier') + ; + } + + /** + * @param InputInterface $input + * @param OutputInterface $output + */ + protected function interact(InputInterface $input, OutputInterface $output) + { + $dialog = $this->getHelperSet()->get('dialog'); + + if (!$input->getArgument('id')) { + $id = $dialog->askAndValidate( + $output, + 'Please give an id:', + function ($id) { + if (empty($id)) { + throw new \InvalidArgumentException('Id cannot be empty!'); + } + + return $id; + } + ); + + $input->setArgument('id', $id); + } + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $pageId = new WebPageId($input->getArgument('id')); + $page = $this->service->read($pageId); + + if ($page) { + $this->bus->register($this->commandName, $this->handler); + $this->bus->handle(new $this->commandName($page)); + } + } +} diff --git a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Command/RemoveWebPageCommand.php b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Command/RemoveWebPageCommand.php new file mode 100644 index 0000000..6b1b506 --- /dev/null +++ b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Command/RemoveWebPageCommand.php @@ -0,0 +1,106 @@ +bus = $bus; + $this->handler = $handler; + $this->service = $service; + $this->commandName = $commandName; + + parent::__construct(); + } + + /** + * + */ + protected function configure() + { + $this + ->setName('black:page:remove') + ->setDescription('Remove a new page') + ->addArgument('id', InputArgument::OPTIONAL, 'The page identifier') + ; + } + + /** + * @param InputInterface $input + * @param OutputInterface $output + */ + protected function interact(InputInterface $input, OutputInterface $output) + { + $dialog = $this->getHelperSet()->get('dialog'); + + if (!$input->getArgument('id')) { + $id = $dialog->askAndValidate( + $output, + 'Please give an id:', + function ($id) { + if (empty($id)) { + throw new \InvalidArgumentException('Id cannot be empty!'); + } + + return $id; + } + ); + + $input->setArgument('id', $id); + } + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $pageId = new WebPageId($input->getArgument('id')); + $page = $this->service->read($pageId); + + if ($page) { + $this->bus->register($this->commandName, $this->handler); + $this->bus->handle(new $this->commandName($page)); + } + } +} diff --git a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Command/WriteWebPageCommand.php b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Command/WriteWebPageCommand.php new file mode 100644 index 0000000..0c3c3ff --- /dev/null +++ b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Command/WriteWebPageCommand.php @@ -0,0 +1,162 @@ +bus = $bus; + $this->handler = $handler; + $this->service = $service; + $this->commandName = $commandName; + + parent::__construct(); + } + + /** + * + */ + protected function configure() + { + $this + ->setName('black:page:write') + ->setDescription('Write a new page') + ->addArgument('id', InputArgument::OPTIONAL, 'The page identifier') + ->addArgument('headline', InputArgument::OPTIONAL, 'The headline') + ->addArgument('about', InputArgument::OPTIONAL, 'The about ') + ->addArgument('text', InputArgument::OPTIONAL, 'The text') + ; + } + + /** + * @param InputInterface $input + * @param OutputInterface $output + */ + protected function interact(InputInterface $input, OutputInterface $output) + { + $dialog = $this->getHelperSet()->get('dialog'); + + if (!$input->getArgument('id')) { + $id = $dialog->askAndValidate( + $output, + 'Please give an id:', + function ($id) { + if (empty($id)) { + throw new \InvalidArgumentException('Id cannot be empty!'); + } + + return $id; + } + ); + + $input->setArgument('id', $id); + } + + if (!$input->getArgument('headline')) { + $headline = $dialog->askAndValidate( + $output, + 'Please give an headline:', + function ($headline) { + if (empty($headline)) { + throw new \InvalidArgumentException('Headline cannot be empty!'); + } + + return $headline; + } + ); + + $input->setArgument('headline', $headline); + } + + if (!$input->getArgument('about')) { + $about = $dialog->askAndValidate( + $output, + 'Please give an about:', + function ($about) { + if (empty($about)) { + throw new \InvalidArgumentException('About cannot be empty!'); + } + + return $about; + } + ); + + $input->setArgument('about', $about); + } + + if (!$input->getArgument('text')) { + $text = $dialog->askAndValidate( + $output, + 'Please give an text:', + function ($text) { + if (empty($text)) { + throw new \InvalidArgumentException('Text cannot be empty!'); + } + + return $text; + } + ); + + $input->setArgument('text', $text); + } + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $pageId = new WebPageId($input->getArgument('id')); + $page = $this->service->read($pageId); + + if ($page) { + $this->bus->register($this->commandName, $this->handler); + $this->bus->handle(new $this->commandName( + $page, + $input->getArgument('headline'), + $input->getArgument('about'), + $input->getArgument('text') + )); + } + } +} diff --git a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/DependencyInjection/BlackPageExtension.php b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/DependencyInjection/BlackPageExtension.php new file mode 100644 index 0000000..c78ee67 --- /dev/null +++ b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/DependencyInjection/BlackPageExtension.php @@ -0,0 +1,114 @@ +getAlias()); + $config = $processor->processConfiguration($configuration, $configs); + + $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../../Resources/config')); + + if (!isset($config['db_driver'])) { + throw new \InvalidArgumentException('You must provide the black_page.db_driver configuration'); + } + + try { + $loader->load(sprintf('%s.xml', $config['db_driver'])); + } catch (\InvalidArgumentException $e) { + throw new \InvalidArgumentException( + sprintf('The db_driver "%s" is not supported by engine', $config['db_driver']) + ); + } + + $container->setParameter($this->getAlias() . '.backend_type_' . $config['db_driver'], true); + + $this->remapParametersNamespaces($config, $container, [ + '' => [ + 'page_class' => 'black_page.webpage.model.class', + ] + ]); + + foreach ( + [ + 'command', + 'application_service', + 'controller', + 'cqrs', + 'domain_event', + 'dto', + 'form', + 'infrastructure_service', + 'specification', + ] as $basename + ) { + $loader->load(sprintf('%s.xml', $basename)); + } + } + + /** + * {@inheritdoc} + * + * @return string + */ + public function getAlias() + { + return 'black_page'; + } + + /** + * @param array $config + * @param ContainerBuilder $container + * @param array $map + */ + protected function remapParameters(array $config, ContainerBuilder $container, array $map) + { + foreach ($map as $name => $paramName) { + if (array_key_exists($name, $config)) { + $container->setParameter($paramName, $config[$name]); + } + } + } + + /** + * @param array $config + * @param ContainerBuilder $container + * @param array $namespaces + */ + protected function remapParametersNamespaces(array $config, ContainerBuilder $container, array $namespaces) + { + foreach ($namespaces as $ns => $map) { + if ($ns) { + if (!array_key_exists($ns, $config)) { + continue; + } + $namespaceConfig = $config[$ns]; + } else { + $namespaceConfig = $config; + } + + if (is_array($map)) { + $this->remapParameters($namespaceConfig, $container, $map); + } else { + foreach ($namespaceConfig as $name => $value) { + $container->setParameter(sprintf($map, $name), $value); + } + } + } + } +} diff --git a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/DependencyInjection/Configuration.php b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/DependencyInjection/Configuration.php new file mode 100644 index 0000000..1171e36 --- /dev/null +++ b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/DependencyInjection/Configuration.php @@ -0,0 +1,52 @@ +alias = $alias; + } + + /** + * {@inheritDoc} + */ + public function getConfigTreeBuilder() + { + $treeBuilder = new TreeBuilder(); + $rootNode = $treeBuilder->root($this->alias); + + $supportedDrivers = ['mongodb', 'orm']; + + $rootNode + ->children() + + ->scalarNode('db_driver') + ->validate() + ->ifNotInArray($supportedDrivers) + ->thenInvalid('The database driver %s is not supported. Please choose one of ' . json_encode($supportedDrivers)) + ->end() + ->isRequired() + ->cannotBeOverwritten() + ->cannotBeEmpty() + ->end() + + ->scalarNode('page_class')->isRequired()->cannotBeEmpty()->end() + ->end(); + + return $treeBuilder; + } +} diff --git a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Form/Handler/CreateWebPageFormHandler.php b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Form/Handler/CreateWebPageFormHandler.php new file mode 100644 index 0000000..80ad9f3 --- /dev/null +++ b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Form/Handler/CreateWebPageFormHandler.php @@ -0,0 +1,21 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Black\Bundle\PageBundle\Application\Form\Handler; + +use Black\Component\Common\Application\Form\Handler\AbstractFormHandler; + +/** + * Class CreateWebPageFormHandler + */ +class CreateWebPageFormHandler extends AbstractFormHandler +{ +} diff --git a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Form/Handler/WriteWebPageFormHandler.php b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Form/Handler/WriteWebPageFormHandler.php new file mode 100644 index 0000000..11a05b0 --- /dev/null +++ b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Form/Handler/WriteWebPageFormHandler.php @@ -0,0 +1,21 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Black\Bundle\PageBundle\Application\Form\Handler; + +use Black\Component\Common\Application\Form\Handler\AbstractFormHandler; + +/** + * Class WriteWebPageFormHandler + */ +class WriteWebPageFormHandler extends AbstractFormHandler +{ +} diff --git a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Form/Type/CreateWebPageType.php b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Form/Type/CreateWebPageType.php new file mode 100644 index 0000000..d70845f --- /dev/null +++ b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Form/Type/CreateWebPageType.php @@ -0,0 +1,81 @@ +class = $class; + $this->name = $name; + } + + /** + * @param FormBuilderInterface $builder + * @param array $options + */ + public function buildForm(FormBuilderInterface $builder, array $options) + { + $builder + ->add('name', 'text', [ + 'label' => 'black.bundle.page.domain.form.type.webpage.name.label', + 'required' => true, + ] + ) + ->add('author', 'text', [ + 'label' => 'black.bundle.page.domain.form.type.webpage.author.label', + 'required' => true, + ] + ); + } + + /** + * @param OptionsResolverInterface $resolver + */ + public function setDefaultOptions(OptionsResolverInterface $resolver) + { + $resolver->setDefaults( + [ + 'data_class' => $this->class, + 'empty_data' => function (FormInterface $form) { + return new $this->class( + null, + $form->get('author')->getData(), + $form->get('name')->getData() + ); + }, + 'translation_domain' => 'form', + ] + ); + } + + /** + * @return string + */ + public function getName() + { + return $this->name; + } +} diff --git a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Form/Type/WriteWebPageType.php b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Form/Type/WriteWebPageType.php new file mode 100644 index 0000000..c5169ba --- /dev/null +++ b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Form/Type/WriteWebPageType.php @@ -0,0 +1,90 @@ +class = $class; + $this->name = $name; + } + + /** + * @param FormBuilderInterface $builder + * @param array $options + */ + public function buildForm(FormBuilderInterface $builder, array $options) + { + $builder + ->add('id', 'hidden') + + ->add('headline', 'text', [ + 'label' => 'black.bundle.page.domain.form.type.webpage.headline.label', + 'required' => false, + ] + ) + + ->add('about', 'textarea', [ + 'label' => 'black.bundle.page.domain.form.type.webpage.about.label', + 'required' => false, + ] + ) + + ->add('text', 'textarea', [ + 'label' => 'black.bundle.page.domain.form.type.webpage.text.label', + ] + ); + } + + /** + * @param OptionsResolverInterface $resolver + */ + public function setDefaultOptions(OptionsResolverInterface $resolver) + { + $resolver->setDefaults( + [ + 'data_class' => $this->class, + 'empty_data' => function (FormInterface $form) { + return new $this->class( + $form->get('id')->getData(), + $form->get('headline')->getData(), + $form->get('about')->getData(), + $form->get('text')->getData() + ); + }, + 'translation_domain' => 'form' + ] + ); + } + + /** + * @return string + */ + public function getName() + { + return $this->name; + } +} diff --git a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/BlackPageBundle.php b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/BlackPageBundle.php new file mode 100644 index 0000000..6c28bb4 --- /dev/null +++ b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/BlackPageBundle.php @@ -0,0 +1,67 @@ +getPath().'/Resources/config/doctrine/model') => 'Black\Page\Domain\Model', + ); + + $ormCompilerClass = 'Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\DoctrineOrmMappingsPass'; + + if (class_exists($ormCompilerClass)) { + $container->addCompilerPass( + DoctrineOrmMappingsPass::createXmlMappingDriver( + $mappings, + [], + 'black_page.backend_type_orm' + )); + } + + $mongoCompilerClass = 'Doctrine\Bundle\MongoDBBundle\DependencyInjection\Compiler\DoctrineMongoDBMappingsPass'; + + if (class_exists($mongoCompilerClass)) { + $container->addCompilerPass( + DoctrineMongoDBMappingsPass::createXmlMappingDriver( + $mappings, + [], + 'black_page.backend_type_mongodb' + )); + } + } + + /** + * {@inheritdoc} + */ + public function registerCommands(Application $application) + { + return; + } +} diff --git a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Infrastructure/Listener/FlashNoticeListener.php b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Infrastructure/Listener/FlashNoticeListener.php new file mode 100644 index 0000000..be1a359 --- /dev/null +++ b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Infrastructure/Listener/FlashNoticeListener.php @@ -0,0 +1,81 @@ + 'black_page.flash.success.created', + WebPageDomainEvents::WEBPAGE_DOMAIN_DEPUBLISHED => 'black_page.flash.success.depublished', + WebPageDomainEvents::WEBPAGE_DOMAIN_PUBLISHED => 'black_page.flash.success.published', + WebPageDomainEvents::WEBPAGE_DOMAIN_REMOVED => 'black_page.flash.success.removed', + WebPageDomainEvents::WEBPAGE_DOMAIN_WRITE => 'black_page.flash.success.write', + ]; + + /** + * @param Session $session + * @param TranslatorInterface $translator + */ + public function __construct(Session $session, TranslatorInterface $translator) + { + $this->session = $session; + $this->translator = $translator; + } + + /** + * @return array + */ + public static function getSubscribedEvents() + { + return [ + WebPageDomainEvents::WEBPAGE_DOMAIN_CREATED => 'addSuccessFlash', + WebPageDomainEvents::WEBPAGE_DOMAIN_DEPUBLISHED => 'addSuccessFlash', + WebPageDomainEvents::WEBPAGE_DOMAIN_PUBLISHED => 'addSuccessFlash', + WebPageDomainEvents::WEBPAGE_DOMAIN_REMOVED => 'addSuccessFlash', + WebPageDomainEvents::WEBPAGE_DOMAIN_WRITE => 'addSuccessFlash', + ]; + } + + /** + * @param Event $event + */ + public function addSuccessFlash(Event $event) + { + if (!isset(self::$successMessages[$event->getName()])) { + throw new \InvalidArgumentException('This event does not correspond to a known flash message'); + } + $this->session->getFlashBag()->add('success', $this->trans(self::$successMessages[$event->getName()])); + } + + /** + * @param $message + * @param array $params + * @return string + */ + private function trans($message, array $params = array()) + { + return $this->translator->trans($message, $params, 'flash'); + } +} diff --git a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/application_service.xml b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/application_service.xml new file mode 100644 index 0000000..d28d7cf --- /dev/null +++ b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/application_service.xml @@ -0,0 +1,20 @@ + + + + + + Black\Page\Application\Service\WebPageReadService + + + + + + + + + + + + diff --git a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/command.xml b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/command.xml new file mode 100644 index 0000000..78e1c67 --- /dev/null +++ b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/command.xml @@ -0,0 +1,57 @@ + + + + + + Black\Bundle\PageBundle\Application\Command\CreateWebPageCommand + Black\Bundle\PageBundle\Application\Command\PublishWebPageCommand + Black\Bundle\PageBundle\Application\Command\DepublishWebPageCommand + Black\Bundle\PageBundle\Application\Command\WriteWebPageCommand + Black\Bundle\PageBundle\Application\Command\RemoveWebPageCommand + + + + + + + + %black_page.infrastructure.cqrs.command.create_web_page.class% + + + + + + + + %black_page.infrastructure.cqrs.command.publish_web_page.class% + + + + + + + + %black_page.infrastructure.cqrs.command.depublish_web_page.class% + + + + + + + + %black_page.infrastructure.cqrs.command.remove_web_page.class% + + + + + + + + %black_page.infrastructure.cqrs.command.write_web_page.class% + + + + + diff --git a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/controller.xml b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/controller.xml new file mode 100644 index 0000000..1ce9756 --- /dev/null +++ b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/controller.xml @@ -0,0 +1,48 @@ + + + + + + Black\Page\Application\Controller\CreatePageController + Black\Page\Application\Controller\WritePageController + Black\Page\Application\Controller\ReadPageController + Black\Page\Application\Controller\PublishPageController + Black\Page\Application\Controller\RemovePageController + + + + + + + + + %black_page.infrastructure.cqrs.command.create_web_page.class% + + + + + + %black_page.infrastructure.cqrs.command.write_web_page.class% + + + + + + %black_page.infrastructure.cqrs.command.publish_web_page.class% + + + + + + %black_page.infrastructure.cqrs.command.remove_web_page.class% + + + + + + + + + diff --git a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/cqrs.xml b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/cqrs.xml new file mode 100644 index 0000000..5d4d713 --- /dev/null +++ b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/cqrs.xml @@ -0,0 +1,54 @@ + + + + + + Black\Page\Infrastructure\CQRS\Command\CreateWebPageCommand + Black\Page\Infrastructure\CQRS\Command\WriteWebPageCommand + Black\Page\Infrastructure\CQRS\Command\PublishWebPageCommand + Black\Page\Infrastructure\CQRS\Command\DepublishWebPageCommand + Black\Page\Infrastructure\CQRS\Command\RemoveWebPageCommand + + Black\Page\Infrastructure\CQRS\Handler\CreateWebPageHandler + Black\Page\Infrastructure\CQRS\Handler\WriteWebPageHandler + Black\Page\Infrastructure\CQRS\Handler\PublishWebPageHandler + Black\Page\Infrastructure\CQRS\Handler\DepublishWebPageHandler + Black\Page\Infrastructure\CQRS\Handler\RemoveWebPageHandler + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/doctrine/model/WebPage.mongodb.xml b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/doctrine/model/WebPage.mongodb.xml new file mode 100644 index 0000000..cb28f5d --- /dev/null +++ b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/doctrine/model/WebPage.mongodb.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/doctrine/model/WebPage.orm.xml b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/doctrine/model/WebPage.orm.xml new file mode 100644 index 0000000..6e9405e --- /dev/null +++ b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/doctrine/model/WebPage.orm.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/doctrine/model/WebPageId.mongodb.xml b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/doctrine/model/WebPageId.mongodb.xml new file mode 100644 index 0000000..9a32506 --- /dev/null +++ b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/doctrine/model/WebPageId.mongodb.xml @@ -0,0 +1,12 @@ + + + + + + + + + diff --git a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/doctrine/model/WebPageId.orm.xml b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/doctrine/model/WebPageId.orm.xml new file mode 100644 index 0000000..a42fd4f --- /dev/null +++ b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/doctrine/model/WebPageId.orm.xml @@ -0,0 +1,12 @@ + + + + + + + + + diff --git a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/domain_event.xml b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/domain_event.xml new file mode 100644 index 0000000..f754517 --- /dev/null +++ b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/domain_event.xml @@ -0,0 +1,28 @@ + + + + + + Black\Page\Domain\Listener\LoggerListener + Black\Bundle\PageBundle\Infrastructure\Listener\FlashNoticeListener + + + + + + + + + + + + + + + + + diff --git a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/dto.xml b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/dto.xml new file mode 100644 index 0000000..75a92ab --- /dev/null +++ b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/dto.xml @@ -0,0 +1,37 @@ + + + + + + Black\Page\Application\DTO\WebPageDTO + Black\Page\Application\DTO\CreateWebPageDTO + Black\Page\Application\DTO\WriteWebPageDTO + Black\Page\Application\DTO\WebPageAssembler + Black\Page\Application\DTO\CreateWebPageAssembler + Black\Page\Application\DTO\WriteWebPageAssembler + + + + + + + + + %black_page.webpage.model.class% + %black_page.application.dto.webpage.class% + + + + %black_page.webpage.model.class% + %black_page.application.dto.create_webpage.class% + + + + %black_page.webpage.model.class% + %black_page.application.dto.write_webpage.class% + + + + diff --git a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/form.xml b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/form.xml new file mode 100644 index 0000000..07200a8 --- /dev/null +++ b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/form.xml @@ -0,0 +1,69 @@ + + + + + + Black\Bundle\PageBundle\Application\Form\Type\CreateWebPageType + Black\Bundle\PageBundle\Application\Form\Type\WriteWebPageType + + Black\Bundle\PageBundle\Application\Form\Handler\CreateWebPageFormHandler + Black\Bundle\PageBundle\Application\Form\Handler\WriteWebPageFormHandler + + black_page_create + black_page_page + + + + + + %black_page.application.dto.create_webpage.class% + %black_page.application.form.create_web_page.name% + + + + + %black_page.application.dto.write_webpage.class% + %black_page.application.form.web_page.name% + + + + + + %black_page.application.form.create_web_page.name% + + null + + + + %black_page.application.form.web_page.name% + + null + + + + + + + + + + + + + + + diff --git a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/infrastructure_service.xml b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/infrastructure_service.xml new file mode 100644 index 0000000..3198529 --- /dev/null +++ b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/infrastructure_service.xml @@ -0,0 +1,23 @@ + + + + + + Black\Page\Infrastructure\Service\WebPageReadService + Black\Page\Infrastructure\Service\WebPageWriteService + + + + + + + + + + + + + + diff --git a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/mongodb.xml b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/mongodb.xml new file mode 100644 index 0000000..0dcd42d --- /dev/null +++ b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/mongodb.xml @@ -0,0 +1,36 @@ + + + + + + Black\Page\Infrastructure\Persistence\MongoDB\ReadRepository + Black\Page\Infrastructure\Persistence\MongoDB\WriteRepository + + + + + + + %black_page.webpage.model.class% + + + + + %black_page.webpage.model.class% + + + + + + + + + diff --git a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/orm.xml b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/orm.xml new file mode 100644 index 0000000..5b3b183 --- /dev/null +++ b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/orm.xml @@ -0,0 +1,36 @@ + + + + + + Black\Page\Infrastructure\Persistence\ORM\ReadRepository + Black\Page\Infrastructure\Persistence\ORM\WriteRepository + + + + + + + %black_page.webpage.model.class% + + + + + %black_page.webpage.model.class% + + + + + + + + + diff --git a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/specification.xml b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/specification.xml new file mode 100644 index 0000000..dc5dcd6 --- /dev/null +++ b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/specification.xml @@ -0,0 +1,16 @@ + + + + + + Black\Page\Application\Specification\PageIsPublishedSpecification + + + + + + + diff --git a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/validation.xml b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/validation.xml new file mode 100644 index 0000000..ac2be71 --- /dev/null +++ b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/validation.xml @@ -0,0 +1,143 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/translations/dto.en.yml b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/translations/dto.en.yml new file mode 100644 index 0000000..2880f5d --- /dev/null +++ b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/translations/dto.en.yml @@ -0,0 +1,37 @@ +black: + bundle: + page: + domain: + dto: + webPageDto: + + author: + validation: + message: + type: This value should be of type "{{ type }}" + length: This value is too long. It should have {{ limit }} characters or less + notblank: This value should not be blank + + name: + validation: + message: + type: This value should be of type "{{ type }}" + length: This value is too long. It should have {{ limit }} characters or less + notblank: This value should not be blank + + headline: + validation: + message: + type: This value should be of type "{{ type }}" + length: This value is too long. It should have {{ limit }} characters or less + notblank: This value should not be blank + + about: + validation: + message: + type: This value should be of type "{{ type }}" + + text: + validation: + message: + type: This value should be of type "{{ type }}" diff --git a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/translations/dto.fr.yml b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/translations/dto.fr.yml new file mode 100644 index 0000000..e4ea291 --- /dev/null +++ b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/translations/dto.fr.yml @@ -0,0 +1,36 @@ +black: + bundle: + page: + domain: + dto: + webPageDto: + author: + validation: + message: + type: Cette valeur doit être de type "{{ type }}" + length: Le texte ne doit pas exceder {{ limit }} caractères + notblank: La valeur ne doit pas être vide ou null + + name: + validation: + message: + type: Cette valeur doit être de type "{{ type }}" + length: Le texte ne doit pas exceder {{ limit }} caractères + notblank: La valeur ne doit pas être vide ou null + + headline: + validation: + message: + type: Cette valeur doit être de type "{{ type }}" + length: Le texte ne doit pas exceder {{ limit }} caractères + notblank: La valeur ne doit pas être vide ou null + + about: + validation: + message: + type: Cette valeur doit être de type "{{ type }}" + + text: + validation: + message: + type: Cette valeur doit être de type "{{ type }}" diff --git a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/translations/flash.en.yml b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/translations/flash.en.yml new file mode 100644 index 0000000..4d5fafe --- /dev/null +++ b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/translations/flash.en.yml @@ -0,0 +1,5 @@ +black_page.flash.success.created: Page has been successfuly created +black_page.flash.success.depublished: Page has been successfuly depublished +black_page.flash.success.published: Page has been successfuly published +black_page.flash.success.removed: Page has been successfuly removed +black_page.flash.success.write: Page has been updated diff --git a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/translations/flash.fr.yml b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/translations/flash.fr.yml new file mode 100644 index 0000000..3e23669 --- /dev/null +++ b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/translations/flash.fr.yml @@ -0,0 +1,5 @@ +black_page.flash.success.created: La page a bien été créée +black_page.flash.success.depublished: La page est maintenant un brouillon +black_page.flash.success.published: La page a bien été publiée +black_page.flash.success.removed: La page a bien été suprimée +black_page.flash.success.write: La page a bien été modifié diff --git a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/translations/form.en.yml b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/translations/form.en.yml new file mode 100644 index 0000000..7bfb280 --- /dev/null +++ b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/translations/form.en.yml @@ -0,0 +1,17 @@ +black: + bundle: + page: + domain: + form: + type: + webpage: + author: + label: Author + name: + label: Name of the page + headline: + label: Headline + about: + label: About + text: + label: Content diff --git a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/translations/form.fr.yml b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/translations/form.fr.yml new file mode 100644 index 0000000..24f3233 --- /dev/null +++ b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/translations/form.fr.yml @@ -0,0 +1,17 @@ +black: + bundle: + page: + domain: + form: + type: + webpage: + author: + label: Auteur + name: + label: Nom de la page + headline: + label: Titre + about: + label: A propos + text: + label: Contenu From 4d09af440f5c41a18ecbec06e0e44ba3a95897cc Mon Sep 17 00:00:00 2001 From: Alexandre 'pocky' Balmes Date: Sun, 21 Feb 2016 00:08:55 +0100 Subject: [PATCH 3/5] Remove unused Symfony classes and move symfony bundles files --- .../Command/CreateWebPageCommand.php | 120 ------------- .../Command/DepublishWebPageCommand.php | 106 ------------ .../Command/PublishWebPageCommand.php | 106 ------------ .../Command/RemoveWebPageCommand.php | 106 ------------ .../Command/WriteWebPageCommand.php | 162 ------------------ .../Form/Handler/CreateWebPageFormHandler.php | 21 --- .../Form/Handler/WriteWebPageFormHandler.php | 21 --- .../Form/Type/CreateWebPageType.php | 81 --------- .../Form/Type/WriteWebPageType.php | 90 ---------- .../Symfony/PageBundle/BlackPageBundle.php | 2 +- .../BlackPageExtension.php | 4 +- .../DependencyInjection/Configuration.php | 2 +- .../Listener/FlashNoticeListener.php | 2 +- .../PageBundle/Resources/config/command.xml | 57 ------ .../Resources/config/domain_event.xml | 2 +- .../PageBundle/Resources/config/form.xml | 69 -------- .../Resources/translations/form.en.yml | 17 -- .../Resources/translations/form.fr.yml | 17 -- 18 files changed, 5 insertions(+), 980 deletions(-) delete mode 100644 src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Command/CreateWebPageCommand.php delete mode 100644 src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Command/DepublishWebPageCommand.php delete mode 100644 src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Command/PublishWebPageCommand.php delete mode 100644 src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Command/RemoveWebPageCommand.php delete mode 100644 src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Command/WriteWebPageCommand.php delete mode 100644 src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Form/Handler/CreateWebPageFormHandler.php delete mode 100644 src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Form/Handler/WriteWebPageFormHandler.php delete mode 100644 src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Form/Type/CreateWebPageType.php delete mode 100644 src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Form/Type/WriteWebPageType.php rename src/Page/Infrastructure/Bridge/Symfony/PageBundle/{Application => }/DependencyInjection/BlackPageExtension.php (96%) rename src/Page/Infrastructure/Bridge/Symfony/PageBundle/{Application => }/DependencyInjection/Configuration.php (95%) rename src/Page/Infrastructure/Bridge/Symfony/PageBundle/{Infrastructure => }/Listener/FlashNoticeListener.php (97%) delete mode 100644 src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/command.xml delete mode 100644 src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/form.xml delete mode 100644 src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/translations/form.en.yml delete mode 100644 src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/translations/form.fr.yml diff --git a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Command/CreateWebPageCommand.php b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Command/CreateWebPageCommand.php deleted file mode 100644 index 14cb896..0000000 --- a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Command/CreateWebPageCommand.php +++ /dev/null @@ -1,120 +0,0 @@ -bus = $bus; - $this->handler = $handler; - $this->commandName = $commandName; - - parent::__construct(); - } - - /** - * - */ - protected function configure() - { - $this - ->setName('black:page:create') - ->setDescription('Create a new page') - ->addArgument('author', InputArgument::OPTIONAL, 'The author') - ->addArgument('name', InputArgument::OPTIONAL, 'The page name'); - } - - /** - * @param InputInterface $input - * @param OutputInterface $output - */ - protected function interact(InputInterface $input, OutputInterface $output) - { - $dialog = $this->getHelperSet()->get('dialog'); - - if (!$input->getArgument('author')) { - $author = $dialog->askAndValidate( - $output, - 'Please give an author name:', - function ($author) { - if (empty($author)) { - throw new \InvalidArgumentException('Author cannot be empty!'); - } - - return $author; - } - ); - - $input->setArgument('author', $author); - } - - if (!$input->getArgument('name')) { - $name = $dialog->askAndValidate( - $output, - 'Please choose a name:', - function ($name) { - if (empty($name)) { - throw new \InvalidArgumentException('Name cannot be empty!'); - } - - return $name; - } - ); - - $input->setArgument('name', $name); - } - } - - protected function execute(InputInterface $input, OutputInterface $output) - { - $pageId = new WebPageId(Uuid::uuid4()); - - $this->bus->register($this->commandName, $this->handler); - $this->bus->handle(new $this->commandName( - $pageId, - $input->getArgument('author'), - $input->getArgument('name') - )); - } -} diff --git a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Command/DepublishWebPageCommand.php b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Command/DepublishWebPageCommand.php deleted file mode 100644 index f8c3b1b..0000000 --- a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Command/DepublishWebPageCommand.php +++ /dev/null @@ -1,106 +0,0 @@ -bus = $bus; - $this->handler = $handler; - $this->service = $service; - $this->commandName = $commandName; - - parent::__construct(); - } - - /** - * - */ - protected function configure() - { - $this - ->setName('black:page:depublish') - ->setDescription('Publish a new page') - ->addArgument('id', InputArgument::OPTIONAL, 'The page identifier') - ; - } - - /** - * @param InputInterface $input - * @param OutputInterface $output - */ - protected function interact(InputInterface $input, OutputInterface $output) - { - $dialog = $this->getHelperSet()->get('dialog'); - - if (!$input->getArgument('id')) { - $id = $dialog->askAndValidate( - $output, - 'Please give an id:', - function ($id) { - if (empty($id)) { - throw new \InvalidArgumentException('Id cannot be empty!'); - } - - return $id; - } - ); - - $input->setArgument('id', $id); - } - } - - protected function execute(InputInterface $input, OutputInterface $output) - { - $pageId = new WebPageId($input->getArgument('id')); - $page = $this->service->read($pageId); - - if ($page) { - $this->bus->register($this->commandName, $this->handler); - $this->bus->handle(new $this->commandName($page)); - } - } -} diff --git a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Command/PublishWebPageCommand.php b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Command/PublishWebPageCommand.php deleted file mode 100644 index 519676b..0000000 --- a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Command/PublishWebPageCommand.php +++ /dev/null @@ -1,106 +0,0 @@ -bus = $bus; - $this->handler = $handler; - $this->service = $service; - $this->commandName = $commandName; - - parent::__construct(); - } - - /** - * - */ - protected function configure() - { - $this - ->setName('black:page:publish') - ->setDescription('Publish a new page') - ->addArgument('id', InputArgument::OPTIONAL, 'The page identifier') - ; - } - - /** - * @param InputInterface $input - * @param OutputInterface $output - */ - protected function interact(InputInterface $input, OutputInterface $output) - { - $dialog = $this->getHelperSet()->get('dialog'); - - if (!$input->getArgument('id')) { - $id = $dialog->askAndValidate( - $output, - 'Please give an id:', - function ($id) { - if (empty($id)) { - throw new \InvalidArgumentException('Id cannot be empty!'); - } - - return $id; - } - ); - - $input->setArgument('id', $id); - } - } - - protected function execute(InputInterface $input, OutputInterface $output) - { - $pageId = new WebPageId($input->getArgument('id')); - $page = $this->service->read($pageId); - - if ($page) { - $this->bus->register($this->commandName, $this->handler); - $this->bus->handle(new $this->commandName($page)); - } - } -} diff --git a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Command/RemoveWebPageCommand.php b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Command/RemoveWebPageCommand.php deleted file mode 100644 index 6b1b506..0000000 --- a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Command/RemoveWebPageCommand.php +++ /dev/null @@ -1,106 +0,0 @@ -bus = $bus; - $this->handler = $handler; - $this->service = $service; - $this->commandName = $commandName; - - parent::__construct(); - } - - /** - * - */ - protected function configure() - { - $this - ->setName('black:page:remove') - ->setDescription('Remove a new page') - ->addArgument('id', InputArgument::OPTIONAL, 'The page identifier') - ; - } - - /** - * @param InputInterface $input - * @param OutputInterface $output - */ - protected function interact(InputInterface $input, OutputInterface $output) - { - $dialog = $this->getHelperSet()->get('dialog'); - - if (!$input->getArgument('id')) { - $id = $dialog->askAndValidate( - $output, - 'Please give an id:', - function ($id) { - if (empty($id)) { - throw new \InvalidArgumentException('Id cannot be empty!'); - } - - return $id; - } - ); - - $input->setArgument('id', $id); - } - } - - protected function execute(InputInterface $input, OutputInterface $output) - { - $pageId = new WebPageId($input->getArgument('id')); - $page = $this->service->read($pageId); - - if ($page) { - $this->bus->register($this->commandName, $this->handler); - $this->bus->handle(new $this->commandName($page)); - } - } -} diff --git a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Command/WriteWebPageCommand.php b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Command/WriteWebPageCommand.php deleted file mode 100644 index 0c3c3ff..0000000 --- a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Command/WriteWebPageCommand.php +++ /dev/null @@ -1,162 +0,0 @@ -bus = $bus; - $this->handler = $handler; - $this->service = $service; - $this->commandName = $commandName; - - parent::__construct(); - } - - /** - * - */ - protected function configure() - { - $this - ->setName('black:page:write') - ->setDescription('Write a new page') - ->addArgument('id', InputArgument::OPTIONAL, 'The page identifier') - ->addArgument('headline', InputArgument::OPTIONAL, 'The headline') - ->addArgument('about', InputArgument::OPTIONAL, 'The about ') - ->addArgument('text', InputArgument::OPTIONAL, 'The text') - ; - } - - /** - * @param InputInterface $input - * @param OutputInterface $output - */ - protected function interact(InputInterface $input, OutputInterface $output) - { - $dialog = $this->getHelperSet()->get('dialog'); - - if (!$input->getArgument('id')) { - $id = $dialog->askAndValidate( - $output, - 'Please give an id:', - function ($id) { - if (empty($id)) { - throw new \InvalidArgumentException('Id cannot be empty!'); - } - - return $id; - } - ); - - $input->setArgument('id', $id); - } - - if (!$input->getArgument('headline')) { - $headline = $dialog->askAndValidate( - $output, - 'Please give an headline:', - function ($headline) { - if (empty($headline)) { - throw new \InvalidArgumentException('Headline cannot be empty!'); - } - - return $headline; - } - ); - - $input->setArgument('headline', $headline); - } - - if (!$input->getArgument('about')) { - $about = $dialog->askAndValidate( - $output, - 'Please give an about:', - function ($about) { - if (empty($about)) { - throw new \InvalidArgumentException('About cannot be empty!'); - } - - return $about; - } - ); - - $input->setArgument('about', $about); - } - - if (!$input->getArgument('text')) { - $text = $dialog->askAndValidate( - $output, - 'Please give an text:', - function ($text) { - if (empty($text)) { - throw new \InvalidArgumentException('Text cannot be empty!'); - } - - return $text; - } - ); - - $input->setArgument('text', $text); - } - } - - protected function execute(InputInterface $input, OutputInterface $output) - { - $pageId = new WebPageId($input->getArgument('id')); - $page = $this->service->read($pageId); - - if ($page) { - $this->bus->register($this->commandName, $this->handler); - $this->bus->handle(new $this->commandName( - $page, - $input->getArgument('headline'), - $input->getArgument('about'), - $input->getArgument('text') - )); - } - } -} diff --git a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Form/Handler/CreateWebPageFormHandler.php b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Form/Handler/CreateWebPageFormHandler.php deleted file mode 100644 index 80ad9f3..0000000 --- a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Form/Handler/CreateWebPageFormHandler.php +++ /dev/null @@ -1,21 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Black\Bundle\PageBundle\Application\Form\Handler; - -use Black\Component\Common\Application\Form\Handler\AbstractFormHandler; - -/** - * Class CreateWebPageFormHandler - */ -class CreateWebPageFormHandler extends AbstractFormHandler -{ -} diff --git a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Form/Handler/WriteWebPageFormHandler.php b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Form/Handler/WriteWebPageFormHandler.php deleted file mode 100644 index 11a05b0..0000000 --- a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Form/Handler/WriteWebPageFormHandler.php +++ /dev/null @@ -1,21 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Black\Bundle\PageBundle\Application\Form\Handler; - -use Black\Component\Common\Application\Form\Handler\AbstractFormHandler; - -/** - * Class WriteWebPageFormHandler - */ -class WriteWebPageFormHandler extends AbstractFormHandler -{ -} diff --git a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Form/Type/CreateWebPageType.php b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Form/Type/CreateWebPageType.php deleted file mode 100644 index d70845f..0000000 --- a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Form/Type/CreateWebPageType.php +++ /dev/null @@ -1,81 +0,0 @@ -class = $class; - $this->name = $name; - } - - /** - * @param FormBuilderInterface $builder - * @param array $options - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - $builder - ->add('name', 'text', [ - 'label' => 'black.bundle.page.domain.form.type.webpage.name.label', - 'required' => true, - ] - ) - ->add('author', 'text', [ - 'label' => 'black.bundle.page.domain.form.type.webpage.author.label', - 'required' => true, - ] - ); - } - - /** - * @param OptionsResolverInterface $resolver - */ - public function setDefaultOptions(OptionsResolverInterface $resolver) - { - $resolver->setDefaults( - [ - 'data_class' => $this->class, - 'empty_data' => function (FormInterface $form) { - return new $this->class( - null, - $form->get('author')->getData(), - $form->get('name')->getData() - ); - }, - 'translation_domain' => 'form', - ] - ); - } - - /** - * @return string - */ - public function getName() - { - return $this->name; - } -} diff --git a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Form/Type/WriteWebPageType.php b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Form/Type/WriteWebPageType.php deleted file mode 100644 index c5169ba..0000000 --- a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/Form/Type/WriteWebPageType.php +++ /dev/null @@ -1,90 +0,0 @@ -class = $class; - $this->name = $name; - } - - /** - * @param FormBuilderInterface $builder - * @param array $options - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - $builder - ->add('id', 'hidden') - - ->add('headline', 'text', [ - 'label' => 'black.bundle.page.domain.form.type.webpage.headline.label', - 'required' => false, - ] - ) - - ->add('about', 'textarea', [ - 'label' => 'black.bundle.page.domain.form.type.webpage.about.label', - 'required' => false, - ] - ) - - ->add('text', 'textarea', [ - 'label' => 'black.bundle.page.domain.form.type.webpage.text.label', - ] - ); - } - - /** - * @param OptionsResolverInterface $resolver - */ - public function setDefaultOptions(OptionsResolverInterface $resolver) - { - $resolver->setDefaults( - [ - 'data_class' => $this->class, - 'empty_data' => function (FormInterface $form) { - return new $this->class( - $form->get('id')->getData(), - $form->get('headline')->getData(), - $form->get('about')->getData(), - $form->get('text')->getData() - ); - }, - 'translation_domain' => 'form' - ] - ); - } - - /** - * @return string - */ - public function getName() - { - return $this->name; - } -} diff --git a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/BlackPageBundle.php b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/BlackPageBundle.php index 6c28bb4..7207070 100644 --- a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/BlackPageBundle.php +++ b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/BlackPageBundle.php @@ -2,7 +2,7 @@ namespace Black\Bundle\PageBundle; -use Black\Bundle\PageBundle\Application\DependencyInjection\BlackPageExtension; +use Black\Bundle\PageBundle\DependencyInjection\BlackPageExtension; use Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\DoctrineOrmMappingsPass; use Doctrine\Bundle\MongoDBBundle\DependencyInjection\Compiler\DoctrineMongoDBMappingsPass; use Symfony\Component\DependencyInjection\ContainerBuilder; diff --git a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/DependencyInjection/BlackPageExtension.php b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/DependencyInjection/BlackPageExtension.php similarity index 96% rename from src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/DependencyInjection/BlackPageExtension.php rename to src/Page/Infrastructure/Bridge/Symfony/PageBundle/DependencyInjection/BlackPageExtension.php index c78ee67..637676d 100644 --- a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Application/DependencyInjection/BlackPageExtension.php +++ b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/DependencyInjection/BlackPageExtension.php @@ -1,6 +1,6 @@ - - - - - Black\Bundle\PageBundle\Application\Command\CreateWebPageCommand - Black\Bundle\PageBundle\Application\Command\PublishWebPageCommand - Black\Bundle\PageBundle\Application\Command\DepublishWebPageCommand - Black\Bundle\PageBundle\Application\Command\WriteWebPageCommand - Black\Bundle\PageBundle\Application\Command\RemoveWebPageCommand - - - - - - - - %black_page.infrastructure.cqrs.command.create_web_page.class% - - - - - - - - %black_page.infrastructure.cqrs.command.publish_web_page.class% - - - - - - - - %black_page.infrastructure.cqrs.command.depublish_web_page.class% - - - - - - - - %black_page.infrastructure.cqrs.command.remove_web_page.class% - - - - - - - - %black_page.infrastructure.cqrs.command.write_web_page.class% - - - - - diff --git a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/domain_event.xml b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/domain_event.xml index f754517..a0bd7a2 100644 --- a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/domain_event.xml +++ b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/domain_event.xml @@ -6,7 +6,7 @@ Black\Page\Domain\Listener\LoggerListener - Black\Bundle\PageBundle\Infrastructure\Listener\FlashNoticeListener + Black\Bundle\PageBundle\Listener\FlashNoticeListener diff --git a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/form.xml b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/form.xml deleted file mode 100644 index 07200a8..0000000 --- a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/form.xml +++ /dev/null @@ -1,69 +0,0 @@ - - - - - - Black\Bundle\PageBundle\Application\Form\Type\CreateWebPageType - Black\Bundle\PageBundle\Application\Form\Type\WriteWebPageType - - Black\Bundle\PageBundle\Application\Form\Handler\CreateWebPageFormHandler - Black\Bundle\PageBundle\Application\Form\Handler\WriteWebPageFormHandler - - black_page_create - black_page_page - - - - - - %black_page.application.dto.create_webpage.class% - %black_page.application.form.create_web_page.name% - - - - - %black_page.application.dto.write_webpage.class% - %black_page.application.form.web_page.name% - - - - - - %black_page.application.form.create_web_page.name% - - null - - - - %black_page.application.form.web_page.name% - - null - - - - - - - - - - - - - - - diff --git a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/translations/form.en.yml b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/translations/form.en.yml deleted file mode 100644 index 7bfb280..0000000 --- a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/translations/form.en.yml +++ /dev/null @@ -1,17 +0,0 @@ -black: - bundle: - page: - domain: - form: - type: - webpage: - author: - label: Author - name: - label: Name of the page - headline: - label: Headline - about: - label: About - text: - label: Content diff --git a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/translations/form.fr.yml b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/translations/form.fr.yml deleted file mode 100644 index 24f3233..0000000 --- a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/translations/form.fr.yml +++ /dev/null @@ -1,17 +0,0 @@ -black: - bundle: - page: - domain: - form: - type: - webpage: - author: - label: Auteur - name: - label: Nom de la page - headline: - label: Titre - about: - label: A propos - text: - label: Contenu From dad4c827f23355057ac1ffce4ace6dd7daa44a50 Mon Sep 17 00:00:00 2001 From: Alexandre 'pocky' Balmes Date: Sun, 21 Feb 2016 00:47:52 +0100 Subject: [PATCH 4/5] Rewrite Infrastructure/Persistence --- .../Domain/Model/WebPageReadRepository.php | 15 ------- .../Domain/Repository/WebPageRepository.php | 23 +++++++++++ .../Resources/config/application_service.xml | 2 +- .../PageBundle/Resources/config/cqrs.xml | 25 ++++++----- .../config/infrastructure_service.xml | 4 +- .../PageBundle/Resources/config/mongodb.xml | 21 +++------- .../PageBundle/Resources/config/orm.xml | 19 +++------ .../Persistence/CQRS/ReadRepository.php | 26 ++++++++++++ .../Persistence/CQRS/WriteRepository.php | 26 ++++++++++++ ...tory.php => DoctrineMongoDBRepository.php} | 37 ++++++++++++++--- ...pository.php => DoctrineORMRepository.php} | 36 +++++++++++++--- .../Persistence/MongoDB/WriteRepository.php | 39 ------------------ .../Persistence/ORM/WriteRepository.php | 41 ------------------- 13 files changed, 164 insertions(+), 150 deletions(-) delete mode 100644 src/Page/Domain/Model/WebPageReadRepository.php create mode 100644 src/Page/Domain/Repository/WebPageRepository.php create mode 100644 src/Page/Infrastructure/Persistence/CQRS/ReadRepository.php create mode 100644 src/Page/Infrastructure/Persistence/CQRS/WriteRepository.php rename src/Page/Infrastructure/Persistence/{MongoDB/ReadRepository.php => DoctrineMongoDBRepository.php} (55%) rename src/Page/Infrastructure/Persistence/{ORM/ReadRepository.php => DoctrineORMRepository.php} (60%) delete mode 100644 src/Page/Infrastructure/Persistence/MongoDB/WriteRepository.php delete mode 100644 src/Page/Infrastructure/Persistence/ORM/WriteRepository.php diff --git a/src/Page/Domain/Model/WebPageReadRepository.php b/src/Page/Domain/Model/WebPageReadRepository.php deleted file mode 100644 index 62b1177..0000000 --- a/src/Page/Domain/Model/WebPageReadRepository.php +++ /dev/null @@ -1,15 +0,0 @@ - - + diff --git a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/cqrs.xml b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/cqrs.xml index 5d4d713..07c618c 100644 --- a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/cqrs.xml +++ b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/cqrs.xml @@ -5,11 +5,8 @@ xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> - Black\Page\Infrastructure\CQRS\Command\CreateWebPageCommand - Black\Page\Infrastructure\CQRS\Command\WriteWebPageCommand - Black\Page\Infrastructure\CQRS\Command\PublishWebPageCommand - Black\Page\Infrastructure\CQRS\Command\DepublishWebPageCommand - Black\Page\Infrastructure\CQRS\Command\RemoveWebPageCommand + Black\Page\Infrastructure\Persistence\CQRS\WriteRepository + Black\Page\Infrastructure\Persistence\CQRS\WriteRepository Black\Page\Infrastructure\CQRS\Handler\CreateWebPageHandler Black\Page\Infrastructure\CQRS\Handler\WriteWebPageHandler @@ -20,34 +17,42 @@ + + + + + + + + - + - + - + - + - + diff --git a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/infrastructure_service.xml b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/infrastructure_service.xml index 3198529..96b133e 100644 --- a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/infrastructure_service.xml +++ b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/infrastructure_service.xml @@ -12,11 +12,11 @@ - + - + diff --git a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/mongodb.xml b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/mongodb.xml index 0dcd42d..0e8255e 100644 --- a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/mongodb.xml +++ b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/mongodb.xml @@ -5,32 +5,21 @@ xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> - Black\Page\Infrastructure\Persistence\MongoDB\ReadRepository - Black\Page\Infrastructure\Persistence\MongoDB\WriteRepository + Black\Page\Infrastructure\Persistence\DoctrineMongoDBRepository %black_page.webpage.model.class% - - - %black_page.webpage.model.class% - - - - - - + + diff --git a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/orm.xml b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/orm.xml index 5b3b183..64c209c 100644 --- a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/orm.xml +++ b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/orm.xml @@ -5,32 +5,23 @@ xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> - Black\Page\Infrastructure\Persistence\ORM\ReadRepository - Black\Page\Infrastructure\Persistence\ORM\WriteRepository + Black\Page\Infrastructure\Persistence\DoctrineORMRepository %black_page.webpage.model.class% - - - %black_page.webpage.model.class% - + - + - - diff --git a/src/Page/Infrastructure/Persistence/CQRS/ReadRepository.php b/src/Page/Infrastructure/Persistence/CQRS/ReadRepository.php new file mode 100644 index 0000000..07b7747 --- /dev/null +++ b/src/Page/Infrastructure/Persistence/CQRS/ReadRepository.php @@ -0,0 +1,26 @@ +repository = $repository; + } + + public function find(WebPageId $id) + { + return $this->repository->find($id); + } + + public function findAll() + { + return $this->repository->findAll(); + } +} diff --git a/src/Page/Infrastructure/Persistence/CQRS/WriteRepository.php b/src/Page/Infrastructure/Persistence/CQRS/WriteRepository.php new file mode 100644 index 0000000..93b9e79 --- /dev/null +++ b/src/Page/Infrastructure/Persistence/CQRS/WriteRepository.php @@ -0,0 +1,26 @@ +repository = $repository; + } + + public function add(WebPage $webpage) + { + $this->repository->add($webpage); + } + + public function update(WebPage $webpage) + { + $this->repository->update($webpage); + } +} diff --git a/src/Page/Infrastructure/Persistence/MongoDB/ReadRepository.php b/src/Page/Infrastructure/Persistence/DoctrineMongoDBRepository.php similarity index 55% rename from src/Page/Infrastructure/Persistence/MongoDB/ReadRepository.php rename to src/Page/Infrastructure/Persistence/DoctrineMongoDBRepository.php index a582594..28f8128 100644 --- a/src/Page/Infrastructure/Persistence/MongoDB/ReadRepository.php +++ b/src/Page/Infrastructure/Persistence/DoctrineMongoDBRepository.php @@ -1,17 +1,18 @@ getQueryBuilder()->getQuery(); } + + /** + * @param WebPage $webpage + */ + public function add(WebPage $webpage) + { + $this->manager->persist($webpage); + $this->update($webpage); + } + + /** + * @param WebPage $webpage + */ + public function remove(WebPage $webpage) + { + $this->manager->remove($webpage); + $this->update($webpage); + + } + + public function update(WebPage $webpage) + { + $this->manager->flush(); + } } diff --git a/src/Page/Infrastructure/Persistence/ORM/ReadRepository.php b/src/Page/Infrastructure/Persistence/DoctrineORMRepository.php similarity index 60% rename from src/Page/Infrastructure/Persistence/ORM/ReadRepository.php rename to src/Page/Infrastructure/Persistence/DoctrineORMRepository.php index 679e965..2dec8d2 100644 --- a/src/Page/Infrastructure/Persistence/ORM/ReadRepository.php +++ b/src/Page/Infrastructure/Persistence/DoctrineORMRepository.php @@ -1,17 +1,17 @@ getQueryBuilder()->getQuery()->execute(); } + + /** + * @param WebPage $webpage + */ + public function add(WebPage $webpage) + { + $this->manager->persist($webpage); + $this->update($webpage); + } + + /** + * @param WebPage $webpage + */ + public function remove(WebPage $webpage) + { + $this->manager->remove($webpage); + $this->update($webpage); + + } + + public function update(WebPage $webpage) + { + $this->manager->flush(); + } } diff --git a/src/Page/Infrastructure/Persistence/MongoDB/WriteRepository.php b/src/Page/Infrastructure/Persistence/MongoDB/WriteRepository.php deleted file mode 100644 index b302559..0000000 --- a/src/Page/Infrastructure/Persistence/MongoDB/WriteRepository.php +++ /dev/null @@ -1,39 +0,0 @@ -manager->persist($website); - } - - /** - * @param WebPage $website - */ - public function remove(WebPage $website) - { - $this->manager->remove($website); - } - - /** - * - */ - public function flush() - { - $this->manager->flush(); - } -} diff --git a/src/Page/Infrastructure/Persistence/ORM/WriteRepository.php b/src/Page/Infrastructure/Persistence/ORM/WriteRepository.php deleted file mode 100644 index c797c7f..0000000 --- a/src/Page/Infrastructure/Persistence/ORM/WriteRepository.php +++ /dev/null @@ -1,41 +0,0 @@ -manager->persist($website); - } - - /** - * @param WebPage $website - */ - public function remove(WebPage $website) - { - $this->manager->remove($website); - } - - /** - * Flushes all changes to objects that have been queued up to now to the database. - * This effectively synchronizes the in-memory state of managed objects with the - * database. - */ - public function flush() - { - $this->manager->flush(); - } -} From 524c80e00a4497b539d87dc9c3e15783ef0254b2 Mon Sep 17 00:00:00 2001 From: Alexandre 'pocky' Balmes Date: Sun, 21 Feb 2016 01:12:30 +0100 Subject: [PATCH 5/5] fix phpdoc, namespaces and DI --- src/Page/Application/Action/CreateWebPage.php | 4 ++-- .../Application/Action/PublishWebPage.php | 4 ++-- src/Page/Application/Action/ReadWebPage.php | 3 +-- src/Page/Application/Action/RemoveWebPage.php | 4 ++-- src/Page/Application/Action/WriteWebPage.php | 4 ++-- .../Service/WebPageReadService.php | 6 +++--- .../Domain/Model/WebPageWriteRepository.php | 13 ------------- .../Listener/FlashNoticeListener.php | 5 ++++- .../PageBundle/Resources/config/cqrs.xml | 2 +- .../config/infrastructure_service.xml | 2 +- .../CQRS/Command/CreateWebPageCommand.php | 2 +- .../CQRS/Command/WriteWebPageCommand.php | 3 ++- .../CQRS/Handler/CreateWebPageHandler.php | 11 ++++++----- .../CQRS/Handler/DepublishWebPageHandler.php | 10 +++++----- .../CQRS/Handler/PublishWebPageHandler.php | 10 ++++------ .../CQRS/Handler/RemoveWebPageHandler.php | 12 ++++++------ .../CQRS/Handler/WriteWebPageHandler.php | 11 +++++------ .../Listener/WebPageCreatedListener.php | 3 +++ .../Listener/WebPageDepublishedListener.php | 5 +++++ .../Listener/WebPagePublishedListener.php | 5 +++++ .../Listener/WebPageRemovedListener.php | 5 +++++ .../Listener/WebPageWritedListener.php | 5 +++++ .../Persistence/CQRS/ReadRepository.php | 18 ++++++++++++++++++ .../Persistence/CQRS/WriteRepository.php | 19 ++++++++++++++++++- .../Persistence/DoctrineMongoDBRepository.php | 7 +++++++ .../Persistence/DoctrineORMRepository.php | 3 +++ .../Service/WebPageReadService.php | 10 ++++++---- .../Service/WebPageWriteService.php | 8 +++++--- 28 files changed, 127 insertions(+), 67 deletions(-) delete mode 100644 src/Page/Domain/Model/WebPageWriteRepository.php diff --git a/src/Page/Application/Action/CreateWebPage.php b/src/Page/Application/Action/CreateWebPage.php index bb20253..32509e6 100644 --- a/src/Page/Application/Action/CreateWebPage.php +++ b/src/Page/Application/Action/CreateWebPage.php @@ -12,7 +12,7 @@ class CreateWebPage { /** - * @var \Black\DDD\CQRSinPHP\Infrastructure\CQRS\Bus + * @var Bus */ protected $bus; @@ -22,7 +22,7 @@ class CreateWebPage protected $commandName; /** - * @var \Black\Page\Infrastructure\CQRS\Handler\CreateWebPageHandler + * @var CreateWebPageHandler */ protected $handler; diff --git a/src/Page/Application/Action/PublishWebPage.php b/src/Page/Application/Action/PublishWebPage.php index aae1088..f98c632 100644 --- a/src/Page/Application/Action/PublishWebPage.php +++ b/src/Page/Application/Action/PublishWebPage.php @@ -12,7 +12,7 @@ class PublishWebPage { /** - * @var \Black\DDD\CQRSinPHP\Infrastructure\CQRS\Bus + * @var Bus */ protected $bus; @@ -22,7 +22,7 @@ class PublishWebPage protected $commandName; /** - * @var \Black\Page\Infrastructure\CQRS\Handler\PublishWebPageHandler + * @var PublishWebPageHandler */ protected $handler; diff --git a/src/Page/Application/Action/ReadWebPage.php b/src/Page/Application/Action/ReadWebPage.php index de37b28..b77c0bb 100644 --- a/src/Page/Application/Action/ReadWebPage.php +++ b/src/Page/Application/Action/ReadWebPage.php @@ -11,7 +11,7 @@ class ReadWebPage { /** - * @var \Black\Page\Application\Service\WebPageReadService + * @var WebPageReadService */ protected $service; @@ -25,7 +25,6 @@ public function __construct(WebPageReadService $service) /** * @param WebPageId $id - * * @return \Black\Page\Application\DTO\WebPageDTO */ public function __invoke(WebPageId $id) diff --git a/src/Page/Application/Action/RemoveWebPage.php b/src/Page/Application/Action/RemoveWebPage.php index 0db124e..dbb0178 100644 --- a/src/Page/Application/Action/RemoveWebPage.php +++ b/src/Page/Application/Action/RemoveWebPage.php @@ -13,7 +13,7 @@ class RemoveWebPage { /** - * @var \Black\DDD\CQRSinPHP\Infrastructure\CQRS\Bus + * @var Bus */ protected $bus; @@ -23,7 +23,7 @@ class RemoveWebPage protected $commandName; /** - * @var \Black\Page\Infrastructure\CQRS\Handler\RemoveWebPageHandler + * @var RemoveWebPageHandler */ protected $handler; diff --git a/src/Page/Application/Action/WriteWebPage.php b/src/Page/Application/Action/WriteWebPage.php index d1b32c5..ce7dae5 100644 --- a/src/Page/Application/Action/WriteWebPage.php +++ b/src/Page/Application/Action/WriteWebPage.php @@ -13,7 +13,7 @@ class WriteWebPage { /** - * @var \Black\DDD\CQRSinPHP\Infrastructure\CQRS\Bus + * @var Bus */ protected $bus; @@ -23,7 +23,7 @@ class WriteWebPage protected $commandName; /** - * @var \Black\Page\Infrastructure\CQRS\Handler\WriteWebPageHandler + * @var WriteWebPageHandler */ protected $handler; diff --git a/src/Page/Application/Service/WebPageReadService.php b/src/Page/Application/Service/WebPageReadService.php index 1b8194c..8f29768 100644 --- a/src/Page/Application/Service/WebPageReadService.php +++ b/src/Page/Application/Service/WebPageReadService.php @@ -24,7 +24,7 @@ class WebPageReadService /** * @var */ - protected $transformer; + protected $assembler; /** * @param PageIsPublishedSpecification $specification @@ -37,8 +37,8 @@ public function __construct( WebPageAssembler $assembler ) { $this->specification = $specification; - $this->service = $service; - $this->assembler = $assembler; + $this->service = $service; + $this->assembler = $assembler; } /** diff --git a/src/Page/Domain/Model/WebPageWriteRepository.php b/src/Page/Domain/Model/WebPageWriteRepository.php deleted file mode 100644 index 1dbfebd..0000000 --- a/src/Page/Domain/Model/WebPageWriteRepository.php +++ /dev/null @@ -1,13 +0,0 @@ - Black\Page\Infrastructure\Persistence\CQRS\WriteRepository - Black\Page\Infrastructure\Persistence\CQRS\WriteRepository + Black\Page\Infrastructure\Persistence\CQRS\ReadRepository Black\Page\Infrastructure\CQRS\Handler\CreateWebPageHandler Black\Page\Infrastructure\CQRS\Handler\WriteWebPageHandler diff --git a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/infrastructure_service.xml b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/infrastructure_service.xml index 96b133e..7ec8b2b 100644 --- a/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/infrastructure_service.xml +++ b/src/Page/Infrastructure/Bridge/Symfony/PageBundle/Resources/config/infrastructure_service.xml @@ -16,7 +16,7 @@ - + diff --git a/src/Page/Infrastructure/CQRS/Command/CreateWebPageCommand.php b/src/Page/Infrastructure/CQRS/Command/CreateWebPageCommand.php index 1e3af27..92d7fc5 100644 --- a/src/Page/Infrastructure/CQRS/Command/CreateWebPageCommand.php +++ b/src/Page/Infrastructure/CQRS/Command/CreateWebPageCommand.php @@ -11,7 +11,7 @@ final class CreateWebPageCommand implements Command { /** - * @var \Black\Page\Domain\Model\WebPageId + * @var WebPageId */ private $webPageId; diff --git a/src/Page/Infrastructure/CQRS/Command/WriteWebPageCommand.php b/src/Page/Infrastructure/CQRS/Command/WriteWebPageCommand.php index e137f70..2b98d7c 100644 --- a/src/Page/Infrastructure/CQRS/Command/WriteWebPageCommand.php +++ b/src/Page/Infrastructure/CQRS/Command/WriteWebPageCommand.php @@ -11,7 +11,7 @@ final class WriteWebPageCommand implements Command { /** - * @var \Black\Page\Domain\Model\WebPage + * @var WebPageId */ private $webPageId; @@ -32,6 +32,7 @@ final class WriteWebPageCommand implements Command /** * WriteWebPageCommand constructor. + * * @param WebPageId $webPageId * @param $headline * @param $about diff --git a/src/Page/Infrastructure/CQRS/Handler/CreateWebPageHandler.php b/src/Page/Infrastructure/CQRS/Handler/CreateWebPageHandler.php index 7152ce6..d9029ce 100644 --- a/src/Page/Infrastructure/CQRS/Handler/CreateWebPageHandler.php +++ b/src/Page/Infrastructure/CQRS/Handler/CreateWebPageHandler.php @@ -3,8 +3,8 @@ namespace Black\Page\Infrastructure\CQRS\Handler; use Black\DDD\CQRSinPHP\Infrastructure\CQRS\Command; -use Black\Page\Domain\Model\WebPageWriteRepository; use Black\Page\Domain\Event\WebPageCreatedEvent; +use Black\Page\Infrastructure\Persistence\CQRS\WriteRepository; use Black\Page\Infrastructure\Service\WebPageWriteService; use Black\Page\WebPageEvents; use Black\DDD\CQRSinPHP\Infrastructure\CQRS\CommandHandler; @@ -21,7 +21,7 @@ final class CreateWebPageHandler implements CommandHandler protected $service; /** - * @var WebPageWriteRepository + * @var WriteRepository */ protected $repository; @@ -31,13 +31,15 @@ final class CreateWebPageHandler implements CommandHandler protected $eventDispatcher; /** + * CreateWebPageHandler constructor. + * * @param WebPageWriteService $service - * @param WebPageWriteRepository $repository + * @param WriteRepository $repository * @param EventDispatcherInterface $eventDispatcher */ public function __construct( WebPageWriteService $service, - WebPageWriteRepository $repository, + WriteRepository $repository, EventDispatcherInterface $eventDispatcher ) { $this->service = $service; @@ -51,7 +53,6 @@ public function __construct( public function handle(Command $command) { $page = $this->service->create($command->getWebPageId(), $command->getAuthor(), $command->getName()); - $this->repository->flush(); $event = new WebPageCreatedEvent($page->getWebPageId()->getValue(), $page->getName()); $this->eventDispatcher->dispatch(WebPageEvents::WEBPAGE_DOMAIN_CREATED, $event); diff --git a/src/Page/Infrastructure/CQRS/Handler/DepublishWebPageHandler.php b/src/Page/Infrastructure/CQRS/Handler/DepublishWebPageHandler.php index b7d5584..b1aaa77 100644 --- a/src/Page/Infrastructure/CQRS/Handler/DepublishWebPageHandler.php +++ b/src/Page/Infrastructure/CQRS/Handler/DepublishWebPageHandler.php @@ -3,8 +3,8 @@ namespace Black\Page\Infrastructure\CQRS\Handler; use Black\DDD\CQRSinPHP\Infrastructure\CQRS\Command; -use Black\Page\Domain\Model\WebPageWriteRepository; use Black\Page\Domain\Event\WebPageDepublishedEvent; +use Black\Page\Infrastructure\Persistence\CQRS\WriteRepository; use Black\Page\Infrastructure\Service\WebPageWriteService; use Black\Page\WebPageEvents; use Black\DDD\CQRSinPHP\Infrastructure\CQRS\CommandHandler; @@ -31,13 +31,15 @@ final class DepublishWebPageHandler implements CommandHandler protected $eventDispatcher; /** + * DepublishWebPageHandler constructor. + * * @param WebPageWriteService $service - * @param WebPageWriteRepository $repository + * @param WriteRepository $repository * @param EventDispatcherInterface $eventDispatcher */ public function __construct( WebPageWriteService $service, - WebPageWriteRepository $repository, + WriteRepository $repository, EventDispatcherInterface $eventDispatcher ) { $this->service = $service; @@ -52,8 +54,6 @@ public function handle(Command $command) { $page = $this->service->depublish($command->getWebPage()); - $this->repository->flush(); - $event = new WebPageDepublishedEvent($page->getWebPageId()->getValue(), $page->getName()); $this->eventDispatcher->dispatch(WebPageEvents::WEBPAGE_DOMAIN_DEPUBLISHED, $event); } diff --git a/src/Page/Infrastructure/CQRS/Handler/PublishWebPageHandler.php b/src/Page/Infrastructure/CQRS/Handler/PublishWebPageHandler.php index 1ce73d3..945e0da 100644 --- a/src/Page/Infrastructure/CQRS/Handler/PublishWebPageHandler.php +++ b/src/Page/Infrastructure/CQRS/Handler/PublishWebPageHandler.php @@ -3,8 +3,8 @@ namespace Black\Page\Infrastructure\CQRS\Handler; use Black\DDD\CQRSinPHP\Infrastructure\CQRS\Command; -use Black\Page\Domain\Model\WebPageWriteRepository; use Black\Page\Domain\Event\WebPagePublishedEvent; +use Black\Page\Infrastructure\Persistence\CQRS\WriteRepository; use Black\Page\Infrastructure\Service\WebPageWriteService; use Black\Page\WebPageEvents; use Black\DDD\CQRSinPHP\Infrastructure\CQRS\CommandHandler; @@ -21,7 +21,7 @@ final class PublishWebPageHandler implements CommandHandler protected $service; /** - * @var WebPageWriteRepository + * @var WriteRepository */ protected $repository; @@ -34,12 +34,12 @@ final class PublishWebPageHandler implements CommandHandler * PublishWebPageHandler constructor. * * @param WebPageWriteService $service - * @param WebPageWriteRepository $repository + * @param WriteRepository $repository * @param EventDispatcherInterface $eventDispatcher */ public function __construct( WebPageWriteService $service, - WebPageWriteRepository $repository, + WriteRepository $repository, EventDispatcherInterface $eventDispatcher ) { $this->service = $service; @@ -54,8 +54,6 @@ public function handle(Command $command) { $page = $this->service->publish($command->getWebPage()); - $this->repository->flush(); - $event = new WebPagePublishedEvent($page->getWebPageId()->getValue(), $page->getName()); $this->eventDispatcher->dispatch(WebPageEvents::WEBPAGE_DOMAIN_PUBLISHED, $event); } diff --git a/src/Page/Infrastructure/CQRS/Handler/RemoveWebPageHandler.php b/src/Page/Infrastructure/CQRS/Handler/RemoveWebPageHandler.php index 748c43f..d975faa 100644 --- a/src/Page/Infrastructure/CQRS/Handler/RemoveWebPageHandler.php +++ b/src/Page/Infrastructure/CQRS/Handler/RemoveWebPageHandler.php @@ -3,8 +3,8 @@ namespace Black\Page\Infrastructure\CQRS\Handler; use Black\DDD\CQRSinPHP\Infrastructure\CQRS\Command; -use Black\Page\Domain\Model\WebPageWriteRepository; use Black\Page\Domain\Event\WebPageRemovedEvent; +use Black\Page\Infrastructure\Persistence\CQRS\WriteRepository; use Black\Page\Infrastructure\Service\WebPageWriteService; use Black\Page\WebPageEvents; use Black\DDD\CQRSinPHP\Infrastructure\CQRS\CommandHandler; @@ -21,7 +21,7 @@ final class RemoveWebPageHandler implements CommandHandler protected $service; /** - * @var WebPageWriteRepository + * @var WriteRepository */ protected $repository; @@ -31,13 +31,15 @@ final class RemoveWebPageHandler implements CommandHandler protected $eventDispatcher; /** + * RemoveWebPageHandler constructor. + * * @param WebPageWriteService $service - * @param WebPageWriteRepository $repository + * @param WriteRepository $repository * @param EventDispatcherInterface $eventDispatcher */ public function __construct( WebPageWriteService $service, - WebPageWriteRepository $repository, + WriteRepository $repository, EventDispatcherInterface $eventDispatcher ) { $this->service = $service; @@ -52,8 +54,6 @@ public function handle(Command $command) { $page = $this->service->remove($command->getWebPage()); - $this->repository->flush(); - $event = new WebPageRemovedEvent($page->getWebPageId()->getValue(), $page->getName()); $this->eventDispatcher->dispatch(WebPageEvents::WEBPAGE_DOMAIN_REMOVED, $event); } diff --git a/src/Page/Infrastructure/CQRS/Handler/WriteWebPageHandler.php b/src/Page/Infrastructure/CQRS/Handler/WriteWebPageHandler.php index 4b7024e..8f238fc 100644 --- a/src/Page/Infrastructure/CQRS/Handler/WriteWebPageHandler.php +++ b/src/Page/Infrastructure/CQRS/Handler/WriteWebPageHandler.php @@ -4,8 +4,8 @@ use Black\DDD\CQRSinPHP\Infrastructure\CQRS\Command; use Black\Page\Domain\Model\WebPageId; -use Black\Page\Domain\Model\WebPageWriteRepository; use Black\Page\Domain\Event\WebPageWritedEvent; +use Black\Page\Infrastructure\Persistence\CQRS\WriteRepository; use Black\Page\Infrastructure\Service\WebPageReadService; use Black\Page\Infrastructure\Service\WebPageWriteService; use Black\Page\WebPageEvents; @@ -28,7 +28,7 @@ final class WriteWebPageHandler implements CommandHandler protected $writeService; /** - * @var WebPageWriteRepository + * @var WriteRepository */ protected $repository; @@ -39,15 +39,16 @@ final class WriteWebPageHandler implements CommandHandler /** * WriteWebPageHandler constructor. + * * @param WebPageReadService $readService * @param WebPageWriteService $writeService - * @param WebPageWriteRepository $repository + * @param WriteRepository $repository * @param EventDispatcherInterface $eventDispatcher */ public function __construct( WebPageReadService $readService, WebPageWriteService $writeService, - WebPageWriteRepository $repository, + WriteRepository $repository, EventDispatcherInterface $eventDispatcher ) { $this->readService = $readService; @@ -69,8 +70,6 @@ public function handle(Command $command) $command->getText() ); - $this->repository->flush(); - $event = new WebPageWritedEvent($page->getWebPageId()->getValue(), $page->getName()); $this->eventDispatcher->dispatch(WebPageEvents::WEBPAGE_DOMAIN_WRITE, $event); } diff --git a/src/Page/Infrastructure/Listener/WebPageCreatedListener.php b/src/Page/Infrastructure/Listener/WebPageCreatedListener.php index d9bec82..fe819a8 100644 --- a/src/Page/Infrastructure/Listener/WebPageCreatedListener.php +++ b/src/Page/Infrastructure/Listener/WebPageCreatedListener.php @@ -11,6 +11,9 @@ */ class WebPageCreatedListener implements EventSubscriberInterface { + /** + * @var Logger + */ protected $logger; /** diff --git a/src/Page/Infrastructure/Listener/WebPageDepublishedListener.php b/src/Page/Infrastructure/Listener/WebPageDepublishedListener.php index a988902..2a0f46d 100644 --- a/src/Page/Infrastructure/Listener/WebPageDepublishedListener.php +++ b/src/Page/Infrastructure/Listener/WebPageDepublishedListener.php @@ -11,6 +11,11 @@ */ class WebPageDepublishedListener implements EventSubscriberInterface { + /** + * @var Logger + */ + protected $logger; + /** * @param Logger $logger */ diff --git a/src/Page/Infrastructure/Listener/WebPagePublishedListener.php b/src/Page/Infrastructure/Listener/WebPagePublishedListener.php index 85a992f..5602026 100644 --- a/src/Page/Infrastructure/Listener/WebPagePublishedListener.php +++ b/src/Page/Infrastructure/Listener/WebPagePublishedListener.php @@ -11,6 +11,11 @@ */ class WebPagePublishedListener implements EventSubscriberInterface { + /** + * @var Logger + */ + protected $logger; + /** * @param Logger $logger */ diff --git a/src/Page/Infrastructure/Listener/WebPageRemovedListener.php b/src/Page/Infrastructure/Listener/WebPageRemovedListener.php index 89f2e70..25dc7cb 100644 --- a/src/Page/Infrastructure/Listener/WebPageRemovedListener.php +++ b/src/Page/Infrastructure/Listener/WebPageRemovedListener.php @@ -11,6 +11,11 @@ */ class WebPageRemovedListener implements EventSubscriberInterface { + /** + * @var Logger + */ + protected $logger; + /** * @param Logger $logger */ diff --git a/src/Page/Infrastructure/Listener/WebPageWritedListener.php b/src/Page/Infrastructure/Listener/WebPageWritedListener.php index 00e5f42..b62c93e 100644 --- a/src/Page/Infrastructure/Listener/WebPageWritedListener.php +++ b/src/Page/Infrastructure/Listener/WebPageWritedListener.php @@ -11,6 +11,11 @@ */ class WebPageWritedListener implements EventSubscriberInterface { + /** + * @var Logger + */ + protected $logger; + /** * @param Logger $logger */ diff --git a/src/Page/Infrastructure/Persistence/CQRS/ReadRepository.php b/src/Page/Infrastructure/Persistence/CQRS/ReadRepository.php index 07b7747..e072586 100644 --- a/src/Page/Infrastructure/Persistence/CQRS/ReadRepository.php +++ b/src/Page/Infrastructure/Persistence/CQRS/ReadRepository.php @@ -5,20 +5,38 @@ use Black\Page\Domain\Model\WebPageId; use Black\Page\Domain\Model\WebPageRepository; +/** + * Class ReadRepository + */ class ReadRepository { + /** + * @var WebPageRepository + */ protected $repository; + /** + * ReadRepository constructor. + * + * @param WebPageRepository $repository + */ public function __construct(WebPageRepository $repository) { $this->repository = $repository; } + /** + * @param WebPageId $id + * @return mixed + */ public function find(WebPageId $id) { return $this->repository->find($id); } + /** + * @return mixed + */ public function findAll() { return $this->repository->findAll(); diff --git a/src/Page/Infrastructure/Persistence/CQRS/WriteRepository.php b/src/Page/Infrastructure/Persistence/CQRS/WriteRepository.php index 93b9e79..419733f 100644 --- a/src/Page/Infrastructure/Persistence/CQRS/WriteRepository.php +++ b/src/Page/Infrastructure/Persistence/CQRS/WriteRepository.php @@ -1,24 +1,41 @@ repository = $repository; } + /** + * @param WebPage $webpage + */ public function add(WebPage $webpage) { $this->repository->add($webpage); } + /** + * @param WebPage $webpage + */ public function update(WebPage $webpage) { $this->repository->update($webpage); diff --git a/src/Page/Infrastructure/Persistence/DoctrineMongoDBRepository.php b/src/Page/Infrastructure/Persistence/DoctrineMongoDBRepository.php index 28f8128..a4c33d8 100644 --- a/src/Page/Infrastructure/Persistence/DoctrineMongoDBRepository.php +++ b/src/Page/Infrastructure/Persistence/DoctrineMongoDBRepository.php @@ -33,6 +33,10 @@ public function find(WebPageId $id) } } + /** + * @param $slug + * @return null + */ public function findBySlug($slug) { $query = $this->getQueryBuilder() @@ -73,6 +77,9 @@ public function remove(WebPage $webpage) } + /** + * @param WebPage $webpage + */ public function update(WebPage $webpage) { $this->manager->flush(); diff --git a/src/Page/Infrastructure/Persistence/DoctrineORMRepository.php b/src/Page/Infrastructure/Persistence/DoctrineORMRepository.php index 2dec8d2..e8f90f4 100644 --- a/src/Page/Infrastructure/Persistence/DoctrineORMRepository.php +++ b/src/Page/Infrastructure/Persistence/DoctrineORMRepository.php @@ -78,6 +78,9 @@ public function remove(WebPage $webpage) } + /** + * @param WebPage $webpage + */ public function update(WebPage $webpage) { $this->manager->flush(); diff --git a/src/Page/Infrastructure/Service/WebPageReadService.php b/src/Page/Infrastructure/Service/WebPageReadService.php index 98bef1f..32ab23c 100644 --- a/src/Page/Infrastructure/Service/WebPageReadService.php +++ b/src/Page/Infrastructure/Service/WebPageReadService.php @@ -4,19 +4,21 @@ use Black\Page\Domain\Exception\WebPageNotFoundException; use Black\Page\Domain\Model\WebPageId; -use Black\Page\Domain\Model\WebPageReadRepository; +use Black\Page\Infrastructure\Persistence\CQRS\ReadRepository; class WebPageReadService { /** - * @var WebPageReadRepository + * @var ReadRepository */ protected $repository; /** - * @param WebPageReadRepository $repository + * WebPageReadService constructor. + * + * @param ReadRepository $repository */ - public function __construct(WebPageReadRepository $repository) + public function __construct(ReadRepository $repository) { $this->repository = $repository; } diff --git a/src/Page/Infrastructure/Service/WebPageWriteService.php b/src/Page/Infrastructure/Service/WebPageWriteService.php index 253b5a3..1723e94 100644 --- a/src/Page/Infrastructure/Service/WebPageWriteService.php +++ b/src/Page/Infrastructure/Service/WebPageWriteService.php @@ -5,12 +5,13 @@ use Black\Page\Domain\Model\WebPage; use Black\Page\Domain\Model\WebPageId; use Black\Page\Domain\Model\WebPageWriteRepository; +use Black\Page\Infrastructure\Persistence\CQRS\WriteRepository; use Cocur\Slugify\Slugify; class WebPageWriteService { /** - * @var WebPageWriteRepository + * @var WriteRepository */ protected $repository; @@ -20,9 +21,10 @@ class WebPageWriteService protected $class; /** - * @param WebPageWriteRepository $repository + * WebPageWriteService constructor. + * @param WriteRepository $repository */ - public function __construct(WebPageWriteRepository $repository) + public function __construct(WriteRepository $repository) { $this->repository = $repository; $this->class = $repository->getClassName();