From 685fbe51885dab7aee511f828278f6a18c45fb23 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Thu, 18 Apr 2019 21:27:51 +0100 Subject: [PATCH] Use class names for service names --- bin/generate-filters.php | 2 +- services.yml | 9 ++------- src/Console/Command/GenerateCommand.php | 1 + src/Container/CommandCompilerClass.php | 3 ++- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/bin/generate-filters.php b/bin/generate-filters.php index 985eac1..d3b85e8 100755 --- a/bin/generate-filters.php +++ b/bin/generate-filters.php @@ -13,6 +13,6 @@ if (file_exists(__DIR__.'/../vendor/autoload.php')) { $container = new Container(); /** @var Application $application */ -$application = $container->get('app.cli'); +$application = $container->get(Application::class); $application->setDefaultCommand(GenerateCommand::NAME); $application->run(); diff --git a/services.yml b/services.yml index 75f8706..b8352c3 100644 --- a/services.yml +++ b/services.yml @@ -1,13 +1,8 @@ services: - app.cli: - class: Symfony\Component\Console\Application + Symfony\Component\Console\Application: autowire: true - app.builder: - class: Opdavies\GmailFilterBuilder\Service\Builder - - app.generate.command: - class: Opdavies\GmailFilterBuilder\Console\Command\GenerateCommand + Opdavies\GmailFilterBuilder\Console\Command\GenerateCommand: autowire: true tags: - { name: ConsoleCommand } diff --git a/src/Console/Command/GenerateCommand.php b/src/Console/Command/GenerateCommand.php index 5586f96..836492a 100644 --- a/src/Console/Command/GenerateCommand.php +++ b/src/Console/Command/GenerateCommand.php @@ -38,6 +38,7 @@ class GenerateCommand extends Command $io = new SymfonyStyle($input, $output); try { + // TODO: Inject this. new Builder($this->filters($input), $outputFile = $this->outputFile($input)); $io->success(sprintf('%s file generated.', $outputFile)); diff --git a/src/Container/CommandCompilerClass.php b/src/Container/CommandCompilerClass.php index 64f441a..5e447ea 100644 --- a/src/Container/CommandCompilerClass.php +++ b/src/Container/CommandCompilerClass.php @@ -2,6 +2,7 @@ namespace Opdavies\GmailFilterBuilder\Container; +use Symfony\Component\Console\Application; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; @@ -13,7 +14,7 @@ class CommandCompilerClass implements CompilerPassInterface */ public function process(ContainerBuilder $container) { - $definition = $container->findDefinition('app.cli'); + $definition = $container->findDefinition(Application::class); $taggedServices = $container->findTaggedServiceIds('ConsoleCommand'); foreach ($taggedServices as $id => $tags) {