Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 8 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| RunTasks | |
0.00% |
0 / 8 |
|
0.00% |
0 / 2 |
12 | |
0.00% |
0 / 1 |
| __invoke | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
2 | |||
| getLimit | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
6 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License |
| 6 | * as published by the Free Software Foundation; under version 2 |
| 7 | * of the License (non-upgradable). |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 17 | * |
| 18 | * Copyright (c) 2014 (original work) Open Assessment Technologies SA; |
| 19 | * |
| 20 | * |
| 21 | */ |
| 22 | |
| 23 | namespace oat\oatbox\task; |
| 24 | |
| 25 | use oat\oatbox\service\ConfigurableService; |
| 26 | use oat\oatbox\action\Action; |
| 27 | |
| 28 | /** |
| 29 | * Class RunTasks is used to run tasks in queue. |
| 30 | * |
| 31 | * Run example: |
| 32 | * ``` |
| 33 | * sudo -u www-data php index.php 'oat\oatbox\task\RunTasks' 10 |
| 34 | * ``` |
| 35 | * @deprecated since version 7.10.0, to be removed in 8.0. Use \oat\taoTaskQueue\scripts\tools\RunWorker instead. |
| 36 | * |
| 37 | * @package oat\oatbox\task |
| 38 | */ |
| 39 | class RunTasks extends ConfigurableService implements Action |
| 40 | { |
| 41 | /** |
| 42 | * @var array |
| 43 | */ |
| 44 | protected $params = []; |
| 45 | |
| 46 | /** |
| 47 | * @param array $params $params[0] (int) tasks limit. If parameter is not given or equals 0 then all tasks in queue |
| 48 | * will be executed. |
| 49 | * @return \common_report_Report |
| 50 | */ |
| 51 | public function __invoke($params) |
| 52 | { |
| 53 | $this->params = $params; |
| 54 | $limit = $this->getLimit(); |
| 55 | $taskService = new TaskService([TaskService::OPTION_LIMIT => $limit]); |
| 56 | $taskService->setServiceLocator($this->getServiceLocator()); |
| 57 | $report = $taskService->runQueue(); |
| 58 | return $report; |
| 59 | } |
| 60 | |
| 61 | /** |
| 62 | * Get max amount of tasks to run. |
| 63 | * @return int |
| 64 | */ |
| 65 | protected function getLimit() |
| 66 | { |
| 67 | $limit = isset($this->params[0]) ? $this->params[0] : 0; |
| 68 | return (int) $limit; |
| 69 | } |
| 70 | } |