Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 13 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| ActionClearAbandonedPositions | |
0.00% |
0 / 13 |
|
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 1 |
| __invoke | |
0.00% |
0 / 13 |
|
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) 2017 (original work) Open Assessment Technologies SA; |
| 19 | * |
| 20 | * |
| 21 | */ |
| 22 | |
| 23 | namespace oat\tao\model\actionQueue\tools; |
| 24 | |
| 25 | use oat\oatbox\extension\AbstractAction; |
| 26 | use oat\tao\model\actionQueue\ActionQueue; |
| 27 | use common_report_Report as Report; |
| 28 | |
| 29 | /** |
| 30 | * Class ActionClearAbandonedPositions |
| 31 | * @author Aleh Hutnikau, <hutnikau@1pt.com> |
| 32 | */ |
| 33 | class ActionClearAbandonedPositions extends AbstractAction |
| 34 | { |
| 35 | public function __invoke($params) |
| 36 | { |
| 37 | $report = new Report(Report::TYPE_INFO, __('Collecting of abandoned actions in the action queue ...')); |
| 38 | /** @var ActionQueue $actionQueueService */ |
| 39 | $actionQueueService = $this->getServiceManager()->get(ActionQueue::SERVICE_ID); |
| 40 | $actions = $actionQueueService->getOption(ActionQueue::OPTION_ACTIONS); |
| 41 | foreach ($actions as $actionClass => $actionConfig) { |
| 42 | $action = new $actionClass(); |
| 43 | $removed = $actionQueueService->clearAbandonedPositions($action); |
| 44 | $report->add( |
| 45 | new Report( |
| 46 | Report::TYPE_SUCCESS, |
| 47 | __('Action %s - removed %s positions', $action->getId(), $removed) |
| 48 | ) |
| 49 | ); |
| 50 | } |
| 51 | return $report; |
| 52 | } |
| 53 | } |