コード例 #1
0
 public function checkLimit(DispatchStopEvent $event)
 {
     $this->events++;
     if ($this->events >= $this->limit) {
         $event->stopDispatching();
     }
 }
コード例 #2
0
 protected function configureControl(InputInterface $input)
 {
     $dispatcher = $this->getDispatcher();
     $events = $input->getOption('events');
     $time = $input->getOption('time');
     // TODO: configure limiters
     $signalCallback = function (StoppableDispatchEvent $event) {
         if (!$this->isActive()) {
             $event->stopDispatching();
         }
     };
     $dispatcher->subscribe(new CallbackSubscription(DispatchStopEvent::name(), $signalCallback));
     $dispatcher->subscribe(new CallbackSubscription(DispatchTimeoutEvent::name(), $signalCallback));
 }
コード例 #3
0
 public function checkLimit(DispatchStopEvent $event)
 {
     if ($this->startTime + $this->limit >= time()) {
         $event->stopDispatching();
     }
 }