Skip to content
Permalink
Browse files

Add logger channel generation for generate:service command (#3841)

  • Loading branch information...
LOBsTerr committed Apr 10, 2019
1 parent 75f5784 commit d80825f213a0533959182d6b916a992497c79a9e
Showing with 25 additions and 1 deletion.
  1. +18 −0 src/Command/Generate/ServiceCommand.php
  2. +7 −1 templates/module/services.yml.twig
@@ -120,6 +120,12 @@ protected function configure()
InputOption::VALUE_OPTIONAL,
$this->trans('commands.generate.service.options.interface-name')
)
->addOption(
'logger-channel',
null,
InputOption::VALUE_NONE,
$this->trans('commands.generate.service.options.logger-channel')
)
->addOption(
'services',
null,
@@ -150,6 +156,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$class = $this->validator->validateClassName($input->getOption('class'));
$interface = $input->getOption('interface');
$interface_name = $input->getOption('interface-name');
$logger_channel = $input->getOption('logger-channel');
$services = $input->getOption('services');
$path_service = $input->getOption('path-service');
@@ -172,6 +179,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
'class' => $class,
'interface' => $interface,
'interface_name' => $interface_name,
'logger_channel' => $logger_channel,
'services' => $build_services,
'path_service' => $path_service,
]);
@@ -231,6 +239,16 @@ function ($class) {
$input->setOption('interface-name', $interface_name);
}
// --logger-channel option
$logger_channel = $input->getOption('logger-channel');
if (!$logger_channel) {
$logger_channel = $this->getIo()->confirm(
$this->trans('commands.generate.service.questions.logger-channel'),
true
);
$input->setOption('logger-channel', $logger_channel);
}
// --services option
$services = $input->getOption('services');
if (!$services) {
@@ -1,7 +1,12 @@
{% if name is defined %}
{% if not file_exists %}
services:
{% endif %}
{% if logger_channel is defined %}
logger.channel.{{ module }}:
parent: logger.channel_base
arguments: ['{{ module }}']
{% endif %}
{% if name is defined %}
{{ name | lower }}:
class: {{ class_path }}
{% if services is defined %}
@@ -11,4 +16,5 @@ services:
tags:
- { {{ tagsAsArray(tags)|join(', ') }} }
{% endif %}

{% endif %}

0 comments on commit d80825f

Please sign in to comment.
You can’t perform that action at this time.