vendor/sylius/sylius/src/Sylius/Bundle/OrderBundle/Command/RemoveExpiredCartsCommand.php line 23

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Sylius package.
  4.  *
  5.  * (c) Paweł Jędrzejewski
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. declare(strict_types=1);
  11. namespace Sylius\Bundle\OrderBundle\Command;
  12. use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
  13. use Symfony\Component\Console\Input\InputInterface;
  14. use Symfony\Component\Console\Output\OutputInterface;
  15. /**
  16.  * @final
  17.  */
  18. class RemoveExpiredCartsCommand extends ContainerAwareCommand
  19. {
  20.     protected static $defaultName 'sylius:remove-expired-carts';
  21.     protected function configure(): void
  22.     {
  23.         $this
  24.             ->setDescription('Removes carts that have been idle for a period set in `sylius_order.expiration.cart` configuration key.')
  25.         ;
  26.     }
  27.     protected function execute(InputInterface $inputOutputInterface $output)
  28.     {
  29.         $expirationTime $this->getContainer()->getParameter('sylius_order.cart_expiration_period');
  30.         $output->writeln(sprintf(
  31.             'Command will remove carts that have been idle for <info>%s</info>.',
  32.             (string) $expirationTime
  33.         ));
  34.         $expiredCartsRemover $this->getContainer()->get('sylius.expired_carts_remover');
  35.         $expiredCartsRemover->remove();
  36.         return 0;
  37.     }
  38. }