Skip to content

Commit

Permalink
Fix archivist command service injection (#35)
Browse files Browse the repository at this point in the history
* Fix typo

* Change ArchiveTokenCommand service injection
  • Loading branch information
halundraN authored and yann-eugone committed Jan 8, 2020
1 parent cc31573 commit d2e32f2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
21 changes: 15 additions & 6 deletions Command/ArchiveTokenCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -11,8 +11,20 @@
/**
* @author Yann Eugoné <[email protected]>
*/
class ArchiveTokenCommand extends ContainerAwareCommand
class ArchiveTokenCommand extends Command
{
/**
* @var ArchivistInterface
*/
private $archivist;

public function __construct(ArchivistInterface $archivist)
{
parent::__construct();

$this->archivist = $archivist;
}

/**
* @inheritDoc
*/
Expand All @@ -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('<info>Successfully archived <comment>%d</comment> security token(s).</info>', $count)
Expand Down
1 change: 1 addition & 0 deletions Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
class="Yokai\SecurityTokenBundle\Command\ArchiveTokenCommand"
public="true">
<tag name="console.command"/>
<argument type="service" id="yokai_security_token.archivist"/>
</service>

</services>
Expand Down
2 changes: 1 addition & 1 deletion Resources/doc/4-archive-command.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
<?php
Expand Down

0 comments on commit d2e32f2

Please sign in to comment.