Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
28.57% |
2 / 7 |
|
66.67% |
2 / 3 |
CRAP | |
0.00% |
0 / 1 |
| MediaRelationService | |
28.57% |
2 / 7 |
|
66.67% |
2 / 3 |
6.28 | |
0.00% |
0 / 1 |
| getMediaRelations | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| findRelations | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 | |||
| getMediaRelationRepository | |
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) 2020 (original work) Open Assessment Technologies SA; |
| 19 | */ |
| 20 | |
| 21 | declare(strict_types=1); |
| 22 | |
| 23 | namespace oat\taoMediaManager\model\relation; |
| 24 | |
| 25 | use oat\oatbox\service\ConfigurableService; |
| 26 | use oat\tao\model\resources\relation\FindAllQuery; |
| 27 | use oat\tao\model\resources\relation\ResourceRelationCollection; |
| 28 | use oat\tao\model\resources\relation\service\ResourceRelationServiceInterface; |
| 29 | use oat\taoMediaManager\model\relation\repository\MediaRelationRepositoryInterface; |
| 30 | use oat\taoMediaManager\model\relation\repository\query\FindAllQuery as LegacyQuery; |
| 31 | |
| 32 | class MediaRelationService extends ConfigurableService implements ResourceRelationServiceInterface |
| 33 | { |
| 34 | /** |
| 35 | * @deprecated Use self::findRelations() |
| 36 | */ |
| 37 | public function getMediaRelations(LegacyQuery $query): MediaRelationCollection |
| 38 | { |
| 39 | return $this->getMediaRelationRepository()->findAll($query); |
| 40 | } |
| 41 | |
| 42 | public function findRelations(FindAllQuery $query): ResourceRelationCollection |
| 43 | { |
| 44 | $legacyQuery = new LegacyQuery( |
| 45 | $query->getSourceId(), |
| 46 | $query->getClassId() |
| 47 | ); |
| 48 | |
| 49 | return $this->getMediaRelationRepository()->findAll($legacyQuery); |
| 50 | } |
| 51 | |
| 52 | private function getMediaRelationRepository(): MediaRelationRepositoryInterface |
| 53 | { |
| 54 | return $this->getServiceLocator()->get(MediaRelationRepositoryInterface::SERVICE_ID); |
| 55 | } |
| 56 | } |