-
Notifications
You must be signed in to change notification settings - Fork 62
Expand file tree
/
Copy pathRemoveAnonymousWishlistsCommand.php
More file actions
55 lines (43 loc) · 1.98 KB
/
Copy pathRemoveAnonymousWishlistsCommand.php
File metadata and controls
55 lines (43 loc) · 1.98 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
51
52
53
54
55
<?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* You can find more information about us on https://bitbag.io and write us
* an email on hello@bitbag.io.
*/
declare(strict_types=1);
namespace BitBag\SyliusWishlistPlugin\Console;
use BitBag\SyliusWishlistPlugin\Remover\AnonymousWishlistsRemoverInterface;
use SyliusLabs\Polyfill\Symfony\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
/**
* @final
*/
class RemoveAnonymousWishlistsCommand extends ContainerAwareCommand
{
protected static $defaultName = 'bitbag:remove-anonymous-wishlists';
protected function configure(): void
{
$this
->setDescription('Removes anonymous wishlists that have been idle for a period set in `bitbag_sylius_wishlist_plugin.parameters.anonymous_wishlist_expiration_period` configuration key.')
;
}
protected function execute(InputInterface $input, OutputInterface $output)
{
/** @var string $expirationTime */
$expirationTime = $this->getContainer()->getParameter('bitbag_sylius_wishlist_plugin.parameters.anonymous_wishlist_expiration_period');
if (empty($expirationTime)) {
$output->writeln('<error>`bitbag_sylius_wishlist_plugin.parameters.anonymous_wishlist_expiration_period` configuration key is not set, so no wishlists will be removed.</error>');
return 0;
}
$output->writeln(sprintf(
'Command will remove anonymous wishlists that have been idle for <info>%s</info>.',
(string) $expirationTime,
));
/** @var AnonymousWishlistsRemoverInterface $anonymousWishlistsRemover */
$anonymousWishlistsRemover = $this->getContainer()->get('bitbag_sylius_wishlist_plugin.services.anonymous_wishlists_remover');
$anonymousWishlistsRemover->remove();
return 0;
}
}