-
Notifications
You must be signed in to change notification settings - Fork 65
/
ResetPasswordRemoveExpiredCommand.php
47 lines (37 loc) · 1.26 KB
/
ResetPasswordRemoveExpiredCommand.php
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
<?php
namespace SymfonyCasts\Bundle\ResetPassword\Command;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use SymfonyCasts\Bundle\ResetPassword\Util\ResetPasswordCleaner;
/**
* @author Jesse Rushlow <jr@rushlow.dev>
* @author Ryan Weaver <ryan@symfonycasts.com>
*/
class ResetPasswordRemoveExpiredCommand extends Command
{
protected static $defaultName = 'reset-password:remove-expired';
private $cleaner;
public function __construct(ResetPasswordCleaner $cleaner)
{
$this->cleaner = $cleaner;
parent::__construct();
}
/**
* @inheritDoc
*/
protected function configure(): void
{
$this->setDescription('Remove expired reset password requests from persistence.');
}
/**
* @inheritDoc
* @psalm-suppress InvalidReturnType
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$output->writeln('Removing expired reset password requests...');
$intRemoved = $this->cleaner->handleGarbageCollection(true);
$output->writeln(\sprintf('Garbage collection successful. Removed %s reset password request objects.', $intRemoved));
}
}