commit 40e6fa63e52900b9753ef9f08d8beb2c202025a1 Author: Jérôme FIX Date: Sat Apr 8 09:18:52 2023 +0200 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..dc75efe --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +/.php-cs-fixer.cache +/vendor +/build +/composer.lock +/auth.json +/.phpunit.result.cache diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php new file mode 100644 index 0000000..0ebf444 --- /dev/null +++ b/.php-cs-fixer.dist.php @@ -0,0 +1,61 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +$header = <<<'HEADER' + This file is part of the zapoyok.info project. + (c) + + For the full copyright and license information, please view the LICENSE + file that was distributed with this source code. + HEADER; + +$finder = PhpCsFixer\Finder::create() + ->in('src/') + ->in('tests/') +; + +$config = new PhpCsFixer\Config(); + +return $config + ->setRiskyAllowed(true) + ->setRules([ + 'header_comment' => ['header' => $header, 'comment_type' => 'PHPDoc', 'location' => 'after_declare_strict'], + '@PHP71Migration' => true, + '@PHP71Migration:risky' => true, + '@PHP73Migration' => true, + '@PhpCsFixer' => true, + '@Symfony' => true, + '@Symfony:risky' => true, + '@DoctrineAnnotation' => true, + 'array_syntax' => ['syntax' => 'short'], + 'general_phpdoc_annotation_remove' => ['annotations' => ['author', 'package', 'subpackage']], + 'no_useless_return' => true, + 'phpdoc_to_comment' => false, + 'method_chaining_indentation' => false, + 'indentation_type' => true, + 'ordered_imports' => true, + 'line_ending' => true, + 'no_superfluous_phpdoc_tags' => true, + 'concat_space' => ['spacing' => 'one'], + 'class_definition' => [ + 'multi_line_extends_each_single_line' => true, + 'single_item_single_line' => false, + 'single_line' => false, + ], + 'php_unit_test_class_requires_covers' => false, + 'phpdoc_order' => true, + 'phpdoc_align' => ['align' => 'vertical'], + 'self_accessor' => false, + ]) + ->setUsingCache(true) + ->setFinder($finder) + ; diff --git a/.yamllint b/.yamllint new file mode 100644 index 0000000..360d9f4 --- /dev/null +++ b/.yamllint @@ -0,0 +1,29 @@ +ignore: | + vendor/ + node_modules/ + .github/ + +extends: default + +rules: + comments: disable + comments-indentation: disable + document-start: disable + empty-lines: + max: 1 + max-start: 0 + max-end: 0 + line-length: disable + truthy: + allowed-values: [ 'true', 'false' ] + check-keys: false + braces: + level: warning + max-spaces-inside: 1 + brackets: + level: warning + max-spaces-inside: 1 + indentation: + spaces: 2 + indent-sequences: true + check-multi-line-strings: false diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e57709f --- /dev/null +++ b/Makefile @@ -0,0 +1,106 @@ +all: + @echo "Please choose a task." +.PHONY: all + +lint: lint-composer lint-yaml lint-xml lint-xliff lint-php +.PHONY: lint + +lint-composer: + composer-normalize --dry-run + composer validate +.PHONY: lint-composer + +lint-yaml: + yamllint . + +.PHONY: lint-yaml + +lint-xml: + find . -name '*.xml' \ + -not -path './vendor/*' \ + -not -path './src/Resources/public/vendor/*' \ + -not -path './src/tests/data/*' \ + | while read xmlFile; \ + do \ + XMLLINT_INDENT=' ' xmllint --encode UTF-8 --format "$$xmlFile"|diff - "$$xmlFile"; \ + if [ $$? -ne 0 ] ;then exit 1; fi; \ + done + +.PHONY: lint-xml + +lint-xliff: + find . -name '*.xlf' \ + -not -path './vendor/*' \ + -not -path './src/Resources/public/vendor/*' \ + | while read xmlFile; \ + do \ + XMLLINT_INDENT=' ' xmllint --encode UTF-8 --format "$$xmlFile"|diff - "$$xmlFile"; \ + if [ $$? -ne 0 ] ;then exit 1; fi; \ + done + +.PHONY: lint-xliff + +lint-php: + vendor/bin/php-cs-fixer fix --verbose --diff --dry-run +.PHONY: lint-php + +lint-symfony: lint-symfony-container lint-symfony-twig lint-symfony-xliff lint-symfony-yaml +.PHONY: lint-symfony + +lint-symfony-container: + bin/console lint:container +.PHONY: lint-symfony-container + +lint-symfony-twig: + bin/console lint:twig src tests +.PHONY: lint-symfony-twig + +lint-symfony-xliff: + bin/console lint:xliff src tests +.PHONY: lint-symfony-xliff + +lint-symfony-yaml: + bin/console lint:yaml src tests +.PHONY: lint-symfony-yaml + +cs-fix: cs-fix-php cs-fix-xml cs-fix-xliff cs-fix-composer +.PHONY: cs-fix + +cs-fix-php: + vendor/bin/php-cs-fixer fix --verbose +.PHONY: cs-fix-php + +cs-fix-xml: + find . -name '*.xml' \ + -not -path './vendor/*' \ + -not -path './src/Resources/public/vendor/*' \ + | while read xmlFile; \ + do \ + XMLLINT_INDENT=' ' xmllint --encode UTF-8 --format "$$xmlFile" --output "$$xmlFile"; \ + done +.PHONY: cs-fix-xml + +cs-fix-xliff: + find . -name '*.xlf' \ + -not -path './vendor/*' \ + -not -path './src/Resources/public/vendor/*' \ + | while read xmlFile; \ + do \ + XMLLINT_INDENT=' ' xmllint --encode UTF-8 --format "$$xmlFile" --output "$$xmlFile"; \ + done +.PHONY: cs-fix-xliff + +cs-fix-composer: + composer-normalize +.PHONY: cs-fix-composer + +build: + mkdir $@ + +test: + vendor/bin/phpunit -c phpunit.xml.dist +.PHONY: test + +coverage: + vendor/bin/phpunit -c phpunit.xml.dist --coverage-clover build/logs/clover.xml --dont-report-useless-tests +.PHONY: coverage diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..2835903 --- /dev/null +++ b/composer.json @@ -0,0 +1,50 @@ +{ + "name": "zapoyok/cqrs-bundle", + "description": "CQRS bundle : interface, bus, Ids, ValueObject, .... ", + "license": "MIT", + "type": "library", + "authors": [ + { + "name": "Jérôme Fix", + "email": "jerome.fix@zapoyok.info" + } + ], + "require": { + "php": "^8.1", + "digital-craftsman/ids": "0.5.*", + "symfony/messenger": "^6.2", + "psr/clock": "^1.0.0", + "symfony/uid": "^6.2" + }, + "require-dev": { + "dg/bypass-finals": "^1.4", + "friendsofphp/php-cs-fixer": "^3.12", + "phpunit/phpunit": "^9.5", + "zapoyok/phpunit-php": "@dev", + "symfony/phpunit-bridge": "^6.2" + }, + "repositories": [ + { + "type": "vcs", + "url": "https://gitlab.zapoyok.info/shared/phpunit-php.git" + } + ], + "autoload": { + "psr-4": { + "Zapoyok\\CQRSBundle\\": "src" + } + }, + "autoload-dev": { + "psr-4": { + "Zapoyok\\Tests\\CQRSBundle\\": "tests" + } + }, + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "scripts": { + "test": "vendor/bin/phpunit -c phpunit.xml.dist" + } +} diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000..90d6d37 --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,30 @@ + + + + + ./src + + + + + + ./tests/ + + + + + + + + + + + + diff --git a/src/Command/AsyncCommandInterface.php b/src/Command/AsyncCommandInterface.php new file mode 100644 index 0000000..073f03e --- /dev/null +++ b/src/Command/AsyncCommandInterface.php @@ -0,0 +1,17 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Zapoyok\CQRSBundle\Command; + +interface AsyncCommandInterface extends CommandInterface +{ +} diff --git a/src/Command/CommandBusInterface.php b/src/Command/CommandBusInterface.php new file mode 100644 index 0000000..642fa1b --- /dev/null +++ b/src/Command/CommandBusInterface.php @@ -0,0 +1,18 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Zapoyok\CQRSBundle\Command; + +interface CommandBusInterface +{ + public function dispatch(CommandInterface $command): void; +} diff --git a/src/Command/CommandHandlerInterface.php b/src/Command/CommandHandlerInterface.php new file mode 100644 index 0000000..6480975 --- /dev/null +++ b/src/Command/CommandHandlerInterface.php @@ -0,0 +1,17 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Zapoyok\CQRSBundle\Command; + +interface CommandHandlerInterface +{ +} diff --git a/src/Command/CommandInterface.php b/src/Command/CommandInterface.php new file mode 100644 index 0000000..fe2be75 --- /dev/null +++ b/src/Command/CommandInterface.php @@ -0,0 +1,17 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Zapoyok\CQRSBundle\Command; + +interface CommandInterface +{ +} diff --git a/src/Command/CommandResponse.php b/src/Command/CommandResponse.php new file mode 100644 index 0000000..a0003f4 --- /dev/null +++ b/src/Command/CommandResponse.php @@ -0,0 +1,28 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Zapoyok\CQRSBundle\Command; + +use DigitalCraftsman\Ids\ValueObject\Id; + +class CommandResponse +{ + public Id $id; + + public static function withValue(Id $id): CommandResponse + { + $response = new self(); + $response->id = $id; + + return $response; + } +} diff --git a/src/Command/MessengerCommandBus.php b/src/Command/MessengerCommandBus.php new file mode 100644 index 0000000..f5d0f72 --- /dev/null +++ b/src/Command/MessengerCommandBus.php @@ -0,0 +1,30 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Zapoyok\CQRSBundle\Command; + +use Symfony\Component\Messenger\MessageBusInterface; + +final class MessengerCommandBus implements CommandBusInterface +{ + private MessageBusInterface $commandBus; + + public function __construct(MessageBusInterface $commandBus) + { + $this->commandBus = $commandBus; + } + + public function dispatch(CommandInterface $command): void + { + $this->commandBus->dispatch($command); + } +} diff --git a/src/Command/SyncCommandInterface.php b/src/Command/SyncCommandInterface.php new file mode 100644 index 0000000..ae1aed5 --- /dev/null +++ b/src/Command/SyncCommandInterface.php @@ -0,0 +1,17 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Zapoyok\CQRSBundle\Command; + +interface SyncCommandInterface extends CommandInterface +{ +} diff --git a/src/DependencyInjection/SccCQRSExtension.php b/src/DependencyInjection/SccCQRSExtension.php new file mode 100644 index 0000000..21ae43f --- /dev/null +++ b/src/DependencyInjection/SccCQRSExtension.php @@ -0,0 +1,32 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Zapoyok\CQRSBundle\DependencyInjection; + +use Symfony\Component\Config\Definition\Processor; +use Symfony\Component\Config\FileLocator; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Extension\Extension; +use Symfony\Component\DependencyInjection\Loader\PhpFileLoader; + +final class SccCQRSExtension extends Extension +{ + public function load(array $configs, ContainerBuilder $container): void + { + $processor = new Processor(); + // $configuration = new Configuration(); + // + // $config = $processor->processConfiguration($configuration, $configs); + $loader = new PhpFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); + $loader->load('services.php'); + } +} diff --git a/src/DomainModel/Clock/Clock.php b/src/DomainModel/Clock/Clock.php new file mode 100644 index 0000000..109baf4 --- /dev/null +++ b/src/DomainModel/Clock/Clock.php @@ -0,0 +1,29 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Zapoyok\CQRSBundle\DomainModel\Clock; + +use Psr\Clock\ClockInterface; + +final class Clock +{ + public function __construct( + private ClockInterface $clock, + ) { + $this->clock = $clock->withTimeZone('UTC'); + } + + public function now(): \DateTimeImmutable + { + return $this->clock->now(); + } +} diff --git a/src/DomainModel/DomainEventInterface.php b/src/DomainModel/DomainEventInterface.php new file mode 100644 index 0000000..36b13ab --- /dev/null +++ b/src/DomainModel/DomainEventInterface.php @@ -0,0 +1,17 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Zapoyok\CQRSBundle\DomainModel; + +interface DomainEventInterface +{ +} diff --git a/src/DomainModel/TriggerEventsTrait.php b/src/DomainModel/TriggerEventsTrait.php new file mode 100644 index 0000000..3d57d75 --- /dev/null +++ b/src/DomainModel/TriggerEventsTrait.php @@ -0,0 +1,35 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Zapoyok\CQRSBundle\DomainModel; + +trait TriggerEventsTrait +{ + /** @var DomainEventInterface[] */ + private array $domainEvents = []; + + /** @return DomainEventInterface[] */ + public function domainEvents(): array + { + return $this->domainEvents; + } + + public function notifyDomainEvent(DomainEventInterface $domainEvent): void + { + $this->domainEvents[] = $domainEvent; + } + + public function resetDomainEvent(): void + { + $this->domainEvents = []; + } +} diff --git a/src/Event/EventBusInterface.php b/src/Event/EventBusInterface.php new file mode 100644 index 0000000..cb2e307 --- /dev/null +++ b/src/Event/EventBusInterface.php @@ -0,0 +1,23 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Zapoyok\CQRSBundle\Event; + +use Scc\CQRSBundle\DomainModel\DomainEventInterface; + +interface EventBusInterface +{ + public function notify(DomainEventInterface $event): void; + + /** @param DomainEventInterface[] $domainEvents */ + public function notifyAll(array $domainEvents): void; +} diff --git a/src/Event/EventHandlerInterface.php b/src/Event/EventHandlerInterface.php new file mode 100644 index 0000000..cbb7720 --- /dev/null +++ b/src/Event/EventHandlerInterface.php @@ -0,0 +1,17 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Zapoyok\CQRSBundle\Event; + +interface EventHandlerInterface +{ +} diff --git a/src/Event/MessengerEventBus.php b/src/Event/MessengerEventBus.php new file mode 100644 index 0000000..5dac820 --- /dev/null +++ b/src/Event/MessengerEventBus.php @@ -0,0 +1,35 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Zapoyok\CQRSBundle\Event; + +use Scc\CQRSBundle\DomainModel\DomainEventInterface; +use Symfony\Component\Messenger\MessageBusInterface; + +final class MessengerEventBus implements EventBusInterface +{ + public function __construct(private MessageBusInterface $eventBus) + { + } + + public function notify(DomainEventInterface $event): void + { + $this->eventBus->dispatch($event); + } + + public function notifyAll(array $domainEvents): void + { + foreach ($domainEvents as $element) { + $this->notify($element); + } + } +} diff --git a/src/MessageId.php b/src/MessageId.php new file mode 100644 index 0000000..9cc1c60 --- /dev/null +++ b/src/MessageId.php @@ -0,0 +1,79 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Zapoyok\CQRSBundle; + +use Symfony\Component\Uid\Uuid; + +// snippet message-id +class MessageId +{ + private string $value; + + final private function __construct() + { + } + + public function __toString() + { + return $this->value; + } + + /** @return static */ + public static function fromUuidRfc4122AsString(string $uuidAsString): self + { + self::checkIsValidUuid($uuidAsString); + + return (new static()) + ->setValue($uuidAsString) + ; + } + + /** @return static */ + final public static function nextId(): self + { + return static::fromUuidRfc4122AsString( + Uuid::v4()->toRfc4122() + ); + } + + public function equals(self $other): bool + { + return $this->value === $other->value; + } + + public function toString(): string + { + return (string) $this; + } + + public function id(): Uuid + { + return Uuid::fromRfc4122($this->value); + } + + /** @return $this */ + private function setValue(string $value): self + { + $this->value = $value; + + return $this; + } + + private static function checkIsValidUuid(string $uuidAsString): void + { + if (!Uuid::isValid($uuidAsString)) { + throw new \InvalidArgumentException('The value does not represent a valid identifier based in Uuid'); + } + } +} +// end-snippet diff --git a/src/MessageTrait.php b/src/MessageTrait.php new file mode 100644 index 0000000..6786765 --- /dev/null +++ b/src/MessageTrait.php @@ -0,0 +1,83 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Zapoyok\CQRSBundle; + +// snippet message-trait +trait MessageTrait +{ + protected ?MessageId $messageId = null; + protected ?MessageId $replyToId = null; + protected ?MessageId $correlationId = null; + + public function stampIds( + ?MessageId $messageId = null, + ?MessageId $replyToId = null, + ?MessageId $correlationId = null + ): static { + $this->messageId = $messageId; + $this->replyToId = $replyToId; + $this->correlationId = $correlationId; + + return $this; + } + + public function stampAsNewMessage(): static + { + $messageId = MessageId::nextId(); + + return $this->stampIds( + $messageId, + null, + $messageId, + ); + } + + public function stampAsResponse( + ?MessageId $replyTo, + ?MessageId $correlationId + ): static { + return $this->stampIds( + MessageId::nextId(), + $replyTo, + $correlationId, + ); + } + + /** + * @param MessageTrait $message + */ + public function stampAsResponseTo($message): static + { + return $this->stampIds( + MessageId::nextId(), + $message->messageId(), + $message->messageCorrelationId() + ); + } + + public function messageId(): ?MessageId + { + return $this->messageId; + } + + public function messageReplyId(): ?MessageId + { + return $this->replyToId; + } + + public function messageCorrelationId(): ?MessageId + { + return $this->correlationId; + } +} +// end-snippet diff --git a/src/Projection/MessengerProjectionBus.php b/src/Projection/MessengerProjectionBus.php new file mode 100644 index 0000000..82c3caf --- /dev/null +++ b/src/Projection/MessengerProjectionBus.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Zapoyok\CQRSBundle\Projection; + +use Symfony\Component\Messenger\MessageBusInterface; + +final class MessengerProjectionBus implements ProjectionBusInterface +{ + public function __construct(private MessageBusInterface $projectionBus) + { + } + + public function project(ProjectionInterface $projection): void + { + $this->projectionBus->dispatch($projection); + } +} diff --git a/src/Projection/ProjectionBusInterface.php b/src/Projection/ProjectionBusInterface.php new file mode 100644 index 0000000..88798c7 --- /dev/null +++ b/src/Projection/ProjectionBusInterface.php @@ -0,0 +1,18 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Zapoyok\CQRSBundle\Projection; + +interface ProjectionBusInterface +{ + public function project(ProjectionInterface $projection): void; +} diff --git a/src/Projection/ProjectionHandlerInterface.php b/src/Projection/ProjectionHandlerInterface.php new file mode 100644 index 0000000..8f7902b --- /dev/null +++ b/src/Projection/ProjectionHandlerInterface.php @@ -0,0 +1,17 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Zapoyok\CQRSBundle\Projection; + +interface ProjectionHandlerInterface +{ +} diff --git a/src/Projection/ProjectionInterface.php b/src/Projection/ProjectionInterface.php new file mode 100644 index 0000000..031fe41 --- /dev/null +++ b/src/Projection/ProjectionInterface.php @@ -0,0 +1,17 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Zapoyok\CQRSBundle\Projection; + +interface ProjectionInterface +{ +} diff --git a/src/Query/MessengerQueryBus.php b/src/Query/MessengerQueryBus.php new file mode 100644 index 0000000..ec3f9f8 --- /dev/null +++ b/src/Query/MessengerQueryBus.php @@ -0,0 +1,33 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Zapoyok\CQRSBundle\Query; + +use Symfony\Component\Messenger\HandleTrait; +use Symfony\Component\Messenger\MessageBusInterface; + +final class MessengerQueryBus implements QueryBusInterface +{ + use HandleTrait { + handle as handleQuery; + } + + public function __construct(MessageBusInterface $queryBus) + { + $this->messageBus = $queryBus; + } + + public function ask(QueryInterface $query): mixed + { + return $this->handleQuery($query); + } +} diff --git a/src/Query/QueryBusInterface.php b/src/Query/QueryBusInterface.php new file mode 100644 index 0000000..3998703 --- /dev/null +++ b/src/Query/QueryBusInterface.php @@ -0,0 +1,18 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Zapoyok\CQRSBundle\Query; + +interface QueryBusInterface +{ + public function ask(QueryInterface $query): mixed; +} diff --git a/src/Query/QueryHandlerInterface.php b/src/Query/QueryHandlerInterface.php new file mode 100644 index 0000000..09d6168 --- /dev/null +++ b/src/Query/QueryHandlerInterface.php @@ -0,0 +1,17 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Zapoyok\CQRSBundle\Query; + +interface QueryHandlerInterface +{ +} diff --git a/src/Query/QueryInterface.php b/src/Query/QueryInterface.php new file mode 100644 index 0000000..084b52e --- /dev/null +++ b/src/Query/QueryInterface.php @@ -0,0 +1,17 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Zapoyok\CQRSBundle\Query; + +interface QueryInterface +{ +} diff --git a/src/Resources/config/services.php b/src/Resources/config/services.php new file mode 100644 index 0000000..3cca2a5 --- /dev/null +++ b/src/Resources/config/services.php @@ -0,0 +1,49 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use Psr\Log\LoggerAwareInterface; +use Scc\VotingBundle\Collection\VotingMethodCollection; +use Scc\VotingBundle\Contract\ElectionMethodAdapterInterface; +use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; + +use function symfony\component\dependencyinjection\loader\configurator\service; +use function Symfony\Component\DependencyInjection\Loader\Configurator\tagged_iterator; + +return static function (ContainerConfigurator $containerConfigurator): void { + $services = $containerConfigurator->services(); + + $services->defaults() + ->public() + ->autowire(true) + ->autoconfigure() + ; + + // $services + // ->instanceof(LoggerAwareInterface::class) + // ->call('setLogger', [service('logger')]); + // + // $services + // ->instanceof(ElectionMethodAdapterInterface::class) + // ->tag('scc_voting.method'); + + $services->load('Scc\CQRSBundle\\', __DIR__ . '/../../../src') + ->exclude([ + __DIR__, + __DIR__ . '/../../../src/SccCQRSBundle.php', + __DIR__ . '/../../../src/{DependencyInjection}', + ]) + ; + + // $services->set(VotingMethodCollection::class) + // ->args([tagged_iterator('scc_voting.method')]); + // $services->alias('scc_voting.method.collection', VotingMethodCollection::class); +}; diff --git a/src/SccCQRSBundle.php b/src/SccCQRSBundle.php new file mode 100644 index 0000000..413af27 --- /dev/null +++ b/src/SccCQRSBundle.php @@ -0,0 +1,19 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Zapoyok\CQRSBundle; + +use Symfony\Component\HttpKernel\Bundle\Bundle; + +final class SccCQRSBundle extends Bundle +{ +} diff --git a/src/ValueObject.php b/src/ValueObject.php new file mode 100644 index 0000000..d8ba508 --- /dev/null +++ b/src/ValueObject.php @@ -0,0 +1,17 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Zapoyok\CQRSBundle; + +abstract class ValueObject +{ +} diff --git a/tests/bootstrap.php b/tests/bootstrap.php new file mode 100644 index 0000000..1636df4 --- /dev/null +++ b/tests/bootstrap.php @@ -0,0 +1,35 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use Doctrine\Deprecations\Deprecation; + +/* + * DO NOT EDIT THIS FILE! + * + * It's auto-generated by sonata-project/dev-kit package. + */ + +/* + * fix encoding issue while running text on different host with different locale configuration + */ +setlocale(\LC_ALL, 'en_US.UTF-8'); + +require_once __DIR__ . '/../vendor/autoload.php'; + +if (class_exists(Deprecation::class)) { + Deprecation::enableWithTriggerError(); +} + +if (file_exists($file = __DIR__ . '/custom_bootstrap.php')) { + require_once $file; +}