-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathArchiveTokenCommand.php
More file actions
50 lines (40 loc) · 1.28 KB
/
Copy pathArchiveTokenCommand.php
File metadata and controls
50 lines (40 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
declare(strict_types=1);
namespace Yokai\SecurityTokenBundle\Command;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Yokai\SecurityTokenBundle\Archive\ArchivistInterface;
/**
* @author Yann Eugoné <eugone.yann@gmail.com>
*/
final class ArchiveTokenCommand extends Command
{
/**
* @var ArchivistInterface
*/
private $archivist;
public function __construct(ArchivistInterface $archivist)
{
$this->archivist = $archivist;
parent::__construct();
}
protected function configure(): void
{
$this
->setName('yokai:security-token:archive')
->addOption('purpose', null, InputOption::VALUE_OPTIONAL, 'Filter tokens to archive on purpose.')
;
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
/** @var string|null $purpose */
$purpose = $input->getOption('purpose');
$count = $this->archivist->archive($purpose);
$output->writeln(
\sprintf('<info>Successfully archived <comment>%d</comment> security token(s).</info>', $count),
);
return 0;
}
}