getServiceManager()->get(Queue::CONFIG_ID); $report = new Report(Report::TYPE_SUCCESS); $limit = $this->getLimit(); foreach ($queue as $task) { $subReport = $queue->runTask($task); $statistics[$subReport->getType()] = isset($statistics[$subReport->getType()]) ? $statistics[$subReport->getType()] + 1 : 1; $report->add($subReport); $count++; if ($limit !== 0 && $count === $limit) { break; } } if (empty($statistics)) { $report = new Report(Report::TYPE_INFO, __('No tasks to run')); } else { if (isset($statistics[Report::TYPE_ERROR]) || isset($statistics[Report::TYPE_WARNING])) { $report->setType(Report::TYPE_WARNING); } $report->setMessage(__('Ran %s task(s):', array_sum($statistics))); } return $report; } /** * @return int */ private function getLimit() { $limit = $this->hasOption(self::OPTION_LIMIT) ? $this->getOption(self::OPTION_LIMIT) : 0; return (int) $limit; } }