Use class names for service names

This commit is contained in:
Oliver Davies 2019-04-18 21:27:51 +01:00
parent 0779825f80
commit 685fbe5188
4 changed files with 6 additions and 9 deletions

View file

@ -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();

View file

@ -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 }

View file

@ -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));

View file

@ -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) {