public function checkLimit(DispatchStopEvent $event) { $this->events++; if ($this->events >= $this->limit) { $event->stopDispatching(); } }
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)); }
public function checkLimit(DispatchStopEvent $event) { if ($this->startTime + $this->limit >= time()) { $event->stopDispatching(); } }