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

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. class RemoveExpiredCartsCommand extends ContainerAwareCommand
  16. {
  17.     /**
  18.      * {@inheritdoc}
  19.      */
  20.     protected function configure(): void
  21.     {
  22.         $this
  23.             ->setName('sylius:remove-expired-carts')
  24.             ->setDescription('Removes carts that have been idle for a period set in `sylius_order.expiration.cart` configuration key.')
  25.         ;
  26.     }
  27.     /**
  28.      * {@inheritdoc}
  29.      */
  30.     protected function execute(InputInterface $inputOutputInterface $output): void
  31.     {
  32.         $expirationTime $this->getContainer()->getParameter('sylius_order.cart_expiration_period');
  33.         $output->writeln(
  34.             sprintf('Command will remove carts that have been idle for <info>%s</info>.'$expirationTime)
  35.         );
  36.         $expiredCartsRemover $this->getContainer()->get('sylius.expired_carts_remover');
  37.         $expiredCartsRemover->remove();
  38.     }
  39. }