Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 11 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
| MediaRelations | |
0.00% |
0 / 11 |
|
0.00% |
0 / 3 |
20 | |
0.00% |
0 / 1 |
| relations | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
6 | |||
| getMediaRelationService | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getQueryFactory | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 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) 2020 (original work) Open Assessment Technologies SA; |
| 19 | */ |
| 20 | |
| 21 | declare(strict_types=1); |
| 22 | |
| 23 | namespace oat\taoMediaManager\controller; |
| 24 | |
| 25 | use oat\oatbox\log\LoggerAwareTrait; |
| 26 | use oat\tao\model\http\HttpJsonResponseTrait; |
| 27 | use oat\taoMediaManager\model\relation\factory\QueryFactory; |
| 28 | use oat\taoMediaManager\model\relation\MediaRelationService; |
| 29 | use tao_actions_CommonModule; |
| 30 | use Throwable; |
| 31 | |
| 32 | /** |
| 33 | * @deprecated use tao_actions_ResourceRelations |
| 34 | */ |
| 35 | class MediaRelations extends tao_actions_CommonModule |
| 36 | { |
| 37 | use LoggerAwareTrait; |
| 38 | use HttpJsonResponseTrait; |
| 39 | |
| 40 | /** |
| 41 | * @deprecated use tao_actions_ResourceRelations |
| 42 | */ |
| 43 | public function relations(): void |
| 44 | { |
| 45 | try { |
| 46 | $query = $this->getQueryFactory() |
| 47 | ->createFindAllQueryByRequest($this->getPsrRequest()); |
| 48 | |
| 49 | $collection = $this->getMediaRelationService() |
| 50 | ->findRelations($query) |
| 51 | ->jsonSerialize(); |
| 52 | |
| 53 | $this->setSuccessJsonResponse($collection); |
| 54 | } catch (Throwable $exception) { |
| 55 | $this->logError(sprintf('Error getting media relation: %s, ', $exception->getMessage())); |
| 56 | |
| 57 | $this->setErrorJsonResponse($exception->getMessage(), $exception->getCode()); |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | private function getMediaRelationService(): MediaRelationService |
| 62 | { |
| 63 | return $this->getServiceLocator()->get(MediaRelationService::class); |
| 64 | } |
| 65 | |
| 66 | private function getQueryFactory(): QueryFactory |
| 67 | { |
| 68 | return $this->getServiceLocator()->get(QueryFactory::class); |
| 69 | } |
| 70 | } |