From d2e32f2435fd5fe5114140f571558bf0e9de5688 Mon Sep 17 00:00:00 2001 From: Alain Flaus Date: Wed, 8 Jan 2020 14:10:43 +0100 Subject: [PATCH] Fix archivist command service injection (#35) * Fix typo * Change ArchiveTokenCommand service injection --- Command/ArchiveTokenCommand.php | 21 +++++++++++++++------ Resources/config/services.xml | 1 + Resources/doc/4-archive-command.md | 2 +- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/Command/ArchiveTokenCommand.php b/Command/ArchiveTokenCommand.php index ef121c5..6a1cab8 100644 --- a/Command/ArchiveTokenCommand.php +++ b/Command/ArchiveTokenCommand.php @@ -2,7 +2,7 @@ namespace Yokai\SecurityTokenBundle\Command; -use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; +use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; @@ -11,8 +11,20 @@ /** * @author Yann Eugoné */ -class ArchiveTokenCommand extends ContainerAwareCommand +class ArchiveTokenCommand extends Command { + /** + * @var ArchivistInterface + */ + private $archivist; + + public function __construct(ArchivistInterface $archivist) + { + parent::__construct(); + + $this->archivist = $archivist; + } + /** * @inheritDoc */ @@ -39,10 +51,7 @@ protected function execute(InputInterface $input, OutputInterface $output) ); } - /** @var $archivist ArchivistInterface */ - $archivist = $this->getContainer()->get('yokai_security_token.archivist'); - - $count = $archivist->archive($purpose); + $count = $this->archivist->archive($purpose); $output->writeln( sprintf('Successfully archived %d security token(s).', $count) diff --git a/Resources/config/services.xml b/Resources/config/services.xml index 76eb30c..75d6e10 100644 --- a/Resources/config/services.xml +++ b/Resources/config/services.xml @@ -84,6 +84,7 @@ class="Yokai\SecurityTokenBundle\Command\ArchiveTokenCommand" public="true"> + diff --git a/Resources/doc/4-archive-command.md b/Resources/doc/4-archive-command.md index b5e46be..5fe0af2 100644 --- a/Resources/doc/4-archive-command.md +++ b/Resources/doc/4-archive-command.md @@ -19,7 +19,7 @@ The command is using the archivist service to perform the operation. ### Creating your own archivist -Fist create a the class that will contain your own logic and the associated service. +Fist create a class that will contain your own logic and the associated service. ```php