Skip to content

Commit

Permalink
Merge pull request #5 from patchlevel/more-commands
Browse files Browse the repository at this point in the history
add more commands
  • Loading branch information
DanielBadura committed Nov 29, 2021
2 parents 5d90d48 + cb92607 commit 9c82421
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 39 deletions.
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -25,7 +25,7 @@ phpunit: vendor
vendor/bin/phpunit --testdox --colors=always -v $(OPTIONS)

.PHONY: static
static: phpstan psalm phpcs-check ## run static analyser
static: psalm phpstan phpcs-check ## run static analyser

test: phpunit ## run tests

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -21,7 +21,7 @@
"php": "^7.4|^8.0",
"ext-json": "^7.4|^8.0",
"doctrine/dbal": "^3.1.4",
"patchlevel/event-sourcing": "1.0.0-alpha",
"patchlevel/event-sourcing": "1.0.0-alpha2",
"psr/simple-cache": "^1.0.1",
"symfony/messenger": "^4.4.18|^5.1.10",
"symfony/dependency-injection": "^4.4.18|^5.1.10",
Expand Down
105 changes: 78 additions & 27 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 38 additions & 10 deletions src/DependencyInjection/PatchlevelEventSourcingExtension.php
Expand Up @@ -8,8 +8,13 @@
use Doctrine\Migrations\Configuration\Migration\ConfigurationArray;
use Doctrine\Migrations\DependencyFactory;
use Doctrine\Migrations\Provider\SchemaProvider;
use Doctrine\Migrations\Tools\Console\Command\CurrentCommand;
use Doctrine\Migrations\Tools\Console\Command\DiffCommand;
use Doctrine\Migrations\Tools\Console\Command\ExecuteCommand;
use Doctrine\Migrations\Tools\Console\Command\MigrateCommand;
use Doctrine\Migrations\Tools\Console\Command\StatusCommand;
use Patchlevel\EventSourcing\Console\Command\DatabaseCreateCommand;
use Patchlevel\EventSourcing\Console\Command\DatabaseDropCommand;
use Patchlevel\EventSourcing\Console\Command\ProjectionCreateCommand;
use Patchlevel\EventSourcing\Console\Command\ProjectionDropCommand;
use Patchlevel\EventSourcing\Console\Command\ProjectionRebuildCommand;
Expand All @@ -18,6 +23,7 @@
use Patchlevel\EventSourcing\Console\Command\SchemaUpdateCommand;
use Patchlevel\EventSourcing\Console\Command\ShowCommand;
use Patchlevel\EventSourcing\Console\Command\WatchCommand;
use Patchlevel\EventSourcing\Console\DoctrineHelper;
use Patchlevel\EventSourcing\EventBus\EventBus;
use Patchlevel\EventSourcing\EventBus\Listener;
use Patchlevel\EventSourcing\EventBus\SymfonyEventBus;
Expand Down Expand Up @@ -176,6 +182,22 @@ private function configureAggregates(array $config, ContainerBuilder $container)
*/
private function configureCommands(array $config, ContainerBuilder $container): void
{
$container->register(DoctrineHelper::class);

$container->register(DatabaseCreateCommand::class)
->setArguments([
new Reference(Store::class),
new Reference(DoctrineHelper::class),
])
->addTag('console.command');

$container->register(DatabaseDropCommand::class)
->setArguments([
new Reference(Store::class),
new Reference(DoctrineHelper::class),
])
->addTag('console.command');

$container->register(SchemaCreateCommand::class)
->setArguments([
new Reference(Store::class),
Expand Down Expand Up @@ -276,17 +298,23 @@ private function configureMigration(array $config, ContainerBuilder $container):
]);

$container->register('event_sourcing.command.diff', DiffCommand::class)
->setArguments([
new Reference('event_sourcing.migration.dependency_factory'),
'event-sourcing:migration:diff',
])
->addTag('console.command');
->setArguments([new Reference('event_sourcing.migration.dependency_factory')])
->addTag('console.command', ['command' => 'event-sourcing:migration:diff']);

$container->register('event_sourcing.command.migrate', MigrateCommand::class)
->setArguments([
new Reference('event_sourcing.migration.dependency_factory'),
'event-sourcing:migration:migrate',
])
->addTag('console.command');
->setArguments([new Reference('event_sourcing.migration.dependency_factory')])
->addTag('console.command', ['command' => 'event-sourcing:migration:migrate']);

$container->register('event_sourcing.command.current', CurrentCommand::class)
->setArguments([new Reference('event_sourcing.migration.dependency_factory')])
->addTag('console.command', ['command' => 'event-sourcing:migration:current']);

$container->register('event_sourcing.command.execute', ExecuteCommand::class)
->setArguments([new Reference('event_sourcing.migration.dependency_factory')])
->addTag('console.command', ['command' => 'event-sourcing:migration:execute']);

$container->register('event_sourcing.command.status', StatusCommand::class)
->setArguments([new Reference('event_sourcing.migration.dependency_factory')])
->addTag('console.command', ['command' => 'event-sourcing:migration:status']);
}
}

0 comments on commit 9c82421

Please sign in to comment.