| @@ 11-46 (lines=36) @@ | ||
| 8 | use Symfony\Component\Console\Input\InputInterface; |
|
| 9 | use Symfony\Component\Console\Output\OutputInterface; |
|
| 10 | ||
| 11 | class CreateDomainEventCommand extends AbstractCommand |
|
| 12 | { |
|
| 13 | /** |
|
| 14 | * {@inheritdoc} |
|
| 15 | */ |
|
| 16 | protected function configure() |
|
| 17 | { |
|
| 18 | $this |
|
| 19 | ->setName('lej-ddd:create-domain-event') |
|
| 20 | ->setDescription('Creates a domain event.') |
|
| 21 | ->addArgument('domain', InputArgument::REQUIRED, 'The name of the domain.') |
|
| 22 | ->addArgument('context', InputArgument::REQUIRED, 'The name of the context.') |
|
| 23 | ->addArgument('name', InputArgument::REQUIRED, 'The name of the domain event.'); |
|
| 24 | } |
|
| 25 | ||
| 26 | /** |
|
| 27 | * {@inheritdoc} |
|
| 28 | */ |
|
| 29 | protected function execute(InputInterface $input, OutputInterface $output) |
|
| 30 | { |
|
| 31 | $twig = $this->twig(); |
|
| 32 | ||
| 33 | $path = $this->modelPath($input->getArgument('domain'), $input->getArgument('context')); |
|
| 34 | $namespace = $this->modelNamespace($input->getArgument('domain'), $input->getArgument('context')); |
|
| 35 | @mkdir($path, 0755, true); |
|
| 36 | ||
| 37 | $eventClassName = $input->getArgument('name'); |
|
| 38 | ||
| 39 | $event = $twig->render('domain_event.php.twig', [ |
|
| 40 | 'namespace' => $namespace, |
|
| 41 | 'eventClassName' => $eventClassName |
|
| 42 | ]); |
|
| 43 | ||
| 44 | file_put_contents($path . '/' . $eventClassName . '.php', $event); |
|
| 45 | } |
|
| 46 | } |
|
| 47 | ||
| @@ 11-46 (lines=36) @@ | ||
| 8 | use Symfony\Component\Console\Input\InputInterface; |
|
| 9 | use Symfony\Component\Console\Output\OutputInterface; |
|
| 10 | ||
| 11 | class CreateStringIdCommand extends AbstractCommand |
|
| 12 | { |
|
| 13 | /** |
|
| 14 | * {@inheritdoc} |
|
| 15 | */ |
|
| 16 | protected function configure() |
|
| 17 | { |
|
| 18 | $this |
|
| 19 | ->setName('lej-ddd:create-string-id') |
|
| 20 | ->setDescription('Creates a string-based identity.') |
|
| 21 | ->addArgument('domain', InputArgument::REQUIRED, 'The name of the domain.') |
|
| 22 | ->addArgument('context', InputArgument::REQUIRED, 'The name of the context.') |
|
| 23 | ->addArgument('name', InputArgument::REQUIRED, 'The name of the identity.'); |
|
| 24 | } |
|
| 25 | ||
| 26 | /** |
|
| 27 | * {@inheritdoc} |
|
| 28 | */ |
|
| 29 | protected function execute(InputInterface $input, OutputInterface $output) |
|
| 30 | { |
|
| 31 | $twig = $this->twig(); |
|
| 32 | ||
| 33 | $path = $this->modelPath($input->getArgument('domain'), $input->getArgument('context')); |
|
| 34 | $namespace = $this->modelNamespace($input->getArgument('domain'), $input->getArgument('context')); |
|
| 35 | @mkdir($path, 0755, true); |
|
| 36 | ||
| 37 | $idClassName = $input->getArgument('name'); |
|
| 38 | ||
| 39 | $id = $twig->render('string_id.php.twig', [ |
|
| 40 | 'namespace' => $namespace, |
|
| 41 | 'idClassName' => $idClassName |
|
| 42 | ]); |
|
| 43 | ||
| 44 | file_put_contents($path . '/' . $idClassName . '.php', $id); |
|
| 45 | } |
|
| 46 | } |
|
| 47 | ||
| @@ 11-46 (lines=36) @@ | ||
| 8 | use Symfony\Component\Console\Input\InputInterface; |
|
| 9 | use Symfony\Component\Console\Output\OutputInterface; |
|
| 10 | ||
| 11 | class CreateUuidIdCommand extends AbstractCommand |
|
| 12 | { |
|
| 13 | /** |
|
| 14 | * {@inheritdoc} |
|
| 15 | */ |
|
| 16 | protected function configure() |
|
| 17 | { |
|
| 18 | $this |
|
| 19 | ->setName('lej-ddd:create-uuid-id') |
|
| 20 | ->setDescription('Creates a UUID-based identity.') |
|
| 21 | ->addArgument('domain', InputArgument::REQUIRED, 'The name of the domain.') |
|
| 22 | ->addArgument('context', InputArgument::REQUIRED, 'The name of the context.') |
|
| 23 | ->addArgument('name', InputArgument::REQUIRED, 'The name of the identity.'); |
|
| 24 | } |
|
| 25 | ||
| 26 | /** |
|
| 27 | * {@inheritdoc} |
|
| 28 | */ |
|
| 29 | protected function execute(InputInterface $input, OutputInterface $output) |
|
| 30 | { |
|
| 31 | $twig = $this->twig(); |
|
| 32 | ||
| 33 | $path = $this->modelPath($input->getArgument('domain'), $input->getArgument('context')); |
|
| 34 | $namespace = $this->modelNamespace($input->getArgument('domain'), $input->getArgument('context')); |
|
| 35 | @mkdir($path, 0755, true); |
|
| 36 | ||
| 37 | $idClassName = $input->getArgument('name'); |
|
| 38 | ||
| 39 | $id = $twig->render('uuid_id.php.twig', [ |
|
| 40 | 'namespace' => $namespace, |
|
| 41 | 'idClassName' => $idClassName |
|
| 42 | ]); |
|
| 43 | ||
| 44 | file_put_contents($path . '/' . $idClassName . '.php', $id); |
|
| 45 | } |
|
| 46 | } |
|
| 47 | ||
| @@ 11-46 (lines=36) @@ | ||
| 8 | use Symfony\Component\Console\Input\InputInterface; |
|
| 9 | use Symfony\Component\Console\Output\OutputInterface; |
|
| 10 | ||
| 11 | class CreateValueObjectCommand extends AbstractCommand |
|
| 12 | { |
|
| 13 | /** |
|
| 14 | * {@inheritdoc} |
|
| 15 | */ |
|
| 16 | protected function configure() |
|
| 17 | { |
|
| 18 | $this |
|
| 19 | ->setName('lej-ddd:create-value-object') |
|
| 20 | ->setDescription('Creates a value object.') |
|
| 21 | ->addArgument('domain', InputArgument::REQUIRED, 'The name of the domain.') |
|
| 22 | ->addArgument('context', InputArgument::REQUIRED, 'The name of the context.') |
|
| 23 | ->addArgument('name', InputArgument::REQUIRED, 'The name of the value object.'); |
|
| 24 | } |
|
| 25 | ||
| 26 | /** |
|
| 27 | * {@inheritdoc} |
|
| 28 | */ |
|
| 29 | protected function execute(InputInterface $input, OutputInterface $output) |
|
| 30 | { |
|
| 31 | $twig = $this->twig(); |
|
| 32 | ||
| 33 | $path = $this->modelPath($input->getArgument('domain'), $input->getArgument('context')); |
|
| 34 | $namespace = $this->modelNamespace($input->getArgument('domain'), $input->getArgument('context')); |
|
| 35 | @mkdir($path, 0755, true); |
|
| 36 | ||
| 37 | $objectClassName = $input->getArgument('name'); |
|
| 38 | ||
| 39 | $object = $twig->render('value_object.php.twig', [ |
|
| 40 | 'namespace' => $namespace, |
|
| 41 | 'objectClassName' => $objectClassName |
|
| 42 | ]); |
|
| 43 | ||
| 44 | file_put_contents($path . '/' . $objectClassName . '.php', $object); |
|
| 45 | } |
|
| 46 | } |
|
| 47 | ||