Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
56.25% |
9 / 16 |
|
66.67% |
2 / 3 |
CRAP | |
0.00% |
0 / 1 |
| SimpleManagementCollectionDecorator | |
56.25% |
9 / 16 |
|
66.67% |
2 / 3 |
9.01 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
1 | |||
| toArray | |
30.00% |
3 / 10 |
|
0.00% |
0 / 1 |
9.49 | |||
| jsonSerialize | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 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 (under the project TAO-PRODUCT); |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | namespace oat\taoTaskQueue\model\TaskLog\Decorator; |
| 23 | |
| 24 | use oat\oatbox\filesystem\FileSystemService; |
| 25 | use oat\tao\model\taskQueue\TaskLog\CollectionInterface; |
| 26 | use oat\tao\model\taskQueue\TaskLogInterface; |
| 27 | use oat\taoTaskQueue\model\Entity\Decorator\CategoryEntityDecorator; |
| 28 | use oat\taoTaskQueue\model\Entity\Decorator\HasFileEntityDecorator; |
| 29 | |
| 30 | /** |
| 31 | * Containing all necessary modification required by the simple UI component. |
| 32 | * |
| 33 | * @deprecated Use \oat\tao\model\taskQueue\TaskLog\Decorator\SimpleManagementCollectionDecorator |
| 34 | * |
| 35 | * @author Gyula Szucs <gyula@taotesting.com> |
| 36 | */ |
| 37 | class SimpleManagementCollectionDecorator extends TaskLogCollectionDecorator |
| 38 | { |
| 39 | /** |
| 40 | * @var CollectionInterface |
| 41 | */ |
| 42 | private $collection; |
| 43 | |
| 44 | /** |
| 45 | * @var TaskLogInterface |
| 46 | */ |
| 47 | private $taskLogService; |
| 48 | |
| 49 | /** |
| 50 | * @var FileSystemService |
| 51 | */ |
| 52 | private $fileSystemService; |
| 53 | |
| 54 | /** |
| 55 | * @var bool |
| 56 | */ |
| 57 | private $reportIncluded; |
| 58 | |
| 59 | public function __construct( |
| 60 | CollectionInterface $collection, |
| 61 | TaskLogInterface $taskLogService, |
| 62 | FileSystemService $fileSystemService, |
| 63 | $reportIncluded |
| 64 | ) { |
| 65 | parent::__construct($collection); |
| 66 | |
| 67 | $this->fileSystemService = $fileSystemService; |
| 68 | $this->collection = $collection; |
| 69 | $this->taskLogService = $taskLogService; |
| 70 | $this->reportIncluded = (bool) $reportIncluded; |
| 71 | } |
| 72 | |
| 73 | /** |
| 74 | * @return array |
| 75 | */ |
| 76 | public function toArray() |
| 77 | { |
| 78 | $data = []; |
| 79 | |
| 80 | foreach ($this->getIterator() as $entity) { |
| 81 | $entityData = (new HasFileEntityDecorator( |
| 82 | new CategoryEntityDecorator($entity, $this->taskLogService), |
| 83 | $this->fileSystemService |
| 84 | ))->toArray(); |
| 85 | |
| 86 | if (!$this->reportIncluded && array_key_exists('report', $entityData)) { |
| 87 | unset($entityData['report']); |
| 88 | } |
| 89 | |
| 90 | $data[] = $entityData; |
| 91 | } |
| 92 | |
| 93 | return $data; |
| 94 | } |
| 95 | |
| 96 | /** |
| 97 | * @return array |
| 98 | */ |
| 99 | public function jsonSerialize() |
| 100 | { |
| 101 | return $this->toArray(); |
| 102 | } |
| 103 | } |