Eased default stream creation

This commit is contained in:
Gildas Quéméner
2018-03-22 15:09:25 +01:00
parent 10540242d6
commit ee6ef3a122
4 changed files with 62 additions and 2 deletions
@@ -3,6 +3,7 @@
"Prooph\\Bundle\\EventStore\\ProophEventStoreBundle": ["all"]
},
"copy-from-recipe": {
"config/": "%CONFIG_DIR%/"
"config/": "%CONFIG_DIR%/",
"src/": "%SRC_DIR%/"
}
}
@@ -0,0 +1,29 @@
<?php
declare(strict_types=1);
namespace App\Command;
use Prooph\EventStore\Stream;
use Prooph\EventStore\StreamName;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class CreateEventStreamCommand extends ContainerAwareCommand
{
protected function configure()
{
$this->setName('event-store:event-stream:create')
->setDescription('Create event_stream.')
->setHelp('This command creates the event_stream');
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$eventStore = $this->getContainer()->get('prooph_event_store.app');
$eventStore->create(new Stream(new StreamName('event_stream'), new \ArrayIterator([])));
$output->writeln('<info>Event stream was created successfully.</info>');
}
}
@@ -3,6 +3,7 @@
"Prooph\\Bundle\\EventStore\\ProophEventStoreBundle": ["all"]
},
"copy-from-recipe": {
"config/": "%CONFIG_DIR%/"
"config/": "%CONFIG_DIR%/",
"src/": "%SRC_DIR%/"
}
}
@@ -0,0 +1,29 @@
<?php
declare(strict_types=1);
namespace App\Command;
use Prooph\EventStore\Stream;
use Prooph\EventStore\StreamName;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class CreateEventStreamCommand extends ContainerAwareCommand
{
protected function configure()
{
$this->setName('event-store:event-stream:create')
->setDescription('Create event_stream.')
->setHelp('This command creates the event_stream');
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$eventStore = $this->getContainer()->get('prooph_event_store.app');
$eventStore->create(new Stream(new StreamName('event_stream'), new \ArrayIterator([])));
$output->writeln('<info>Event stream was created successfully.</info>');
}
}