vendor/shapecode/cron-bundle/src/EventListener/ResultAutoPruneListener.php line 35

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Shapecode\Bundle\CronBundle\EventListener;
  4. use Shapecode\Bundle\CronBundle\Event\GenericCleanUpEvent;
  5. use Shapecode\Bundle\CronBundle\Service\CronJobResultServiceInterface;
  6. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  7. final class ResultAutoPruneListener implements EventSubscriberInterface
  8. {
  9.     /** @var CronJobResultServiceInterface */
  10.     private $cronjobService;
  11.     /** @var bool */
  12.     private $autoPrune;
  13.     public function __construct(CronJobResultServiceInterface $cronjobServicebool $autoPrune)
  14.     {
  15.         $this->cronjobService $cronjobService;
  16.         $this->autoPrune      $autoPrune;
  17.     }
  18.     /**
  19.      * @inheritDoc
  20.      */
  21.     public static function getSubscribedEvents() : array
  22.     {
  23.         return [
  24.             GenericCleanUpEvent::HOURLY_PROCESS => 'onHourlyProcess',
  25.         ];
  26.     }
  27.     public function onHourlyProcess(GenericCleanUpEvent $genericCleanUpEvent) : void
  28.     {
  29.         if (! $this->autoPrune) {
  30.             return;
  31.         }
  32.         $this->cronjobService->prune();
  33.     }
  34. }