Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 47 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
| tao_actions_PropertyValues | |
0.00% |
0 / 47 |
|
0.00% |
0 / 4 |
56 | |
0.00% |
0 / 1 |
| get | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 | |||
| getDependOnPropertyList | |
0.00% |
0 / 21 |
|
0.00% |
0 / 1 |
20 | |||
| getDependentProperties | |
0.00% |
0 / 20 |
|
0.00% |
0 / 1 |
2 | |||
| getRepository | |
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-2021 (original work) Open Assessment Technologies SA; |
| 19 | * |
| 20 | * @author Sergei Mikhailov <sergei.mikhailov@taotesting.com> |
| 21 | */ |
| 22 | |
| 23 | declare(strict_types=1); |
| 24 | |
| 25 | use GuzzleHttp\Psr7\ServerRequest; |
| 26 | use oat\generis\model\OntologyAwareTrait; |
| 27 | use oat\tao\model\http\HttpJsonResponseTrait; |
| 28 | use oat\tao\model\Lists\Business\Contract\DependsOnPropertyRepositoryInterface; |
| 29 | use oat\tao\model\Lists\Business\Service\ValueCollectionService; |
| 30 | use oat\tao\model\Lists\DataAccess\Repository\DependsOnPropertyRepository; |
| 31 | use oat\tao\model\Lists\DataAccess\Repository\DependentPropertiesRepository; |
| 32 | use oat\tao\model\Lists\Business\Domain\DependentPropertiesRepositoryContext; |
| 33 | use oat\tao\model\Lists\Presentation\Web\RequestHandler\ValueCollectionSearchRequestHandler; |
| 34 | |
| 35 | class tao_actions_PropertyValues extends tao_actions_CommonModule |
| 36 | { |
| 37 | use HttpJsonResponseTrait; |
| 38 | use OntologyAwareTrait; |
| 39 | |
| 40 | public function get( |
| 41 | ServerRequest $request, |
| 42 | ValueCollectionSearchRequestHandler $valueCollectionSearchRequestHandler, |
| 43 | ValueCollectionService $valueCollectionService |
| 44 | ): void { |
| 45 | $this->setSuccessJsonResponse( |
| 46 | $valueCollectionService->findAll( |
| 47 | $valueCollectionSearchRequestHandler->handle($request) |
| 48 | ) |
| 49 | ); |
| 50 | } |
| 51 | |
| 52 | public function getDependOnPropertyList(): void |
| 53 | { |
| 54 | $property = $this->hasGetParameter('property_uri') |
| 55 | ? $this->getProperty(tao_helpers_Uri::decode($this->getGetParameter('property_uri'))) |
| 56 | : null; |
| 57 | |
| 58 | $class = $this->hasGetParameter('class_uri') |
| 59 | ? $this->getClass(tao_helpers_Uri::decode($this->getGetParameter('class_uri'))) |
| 60 | : null; |
| 61 | |
| 62 | $widgetUri = $this->hasGetParameter('type') |
| 63 | ? tao_helpers_form_GenerisFormFactory::getWidgetUriById($this->getGetParameter('type')) |
| 64 | : null; |
| 65 | |
| 66 | $this->setSuccessJsonResponse( |
| 67 | $this->getRepository()->findAll( |
| 68 | [ |
| 69 | DependsOnPropertyRepositoryInterface::FILTER_PROPERTY_WIDGET_URI => $widgetUri, |
| 70 | DependsOnPropertyRepositoryInterface::FILTER_PROPERTY => $property, |
| 71 | DependsOnPropertyRepositoryInterface::FILTER_CLASS => $class, |
| 72 | DependsOnPropertyRepositoryInterface::FILTER_LIST_URI => $this->getProperty( |
| 73 | tao_helpers_Uri::decode($this->getGetParameter('list_uri')) |
| 74 | )->getUri() |
| 75 | ] |
| 76 | ) |
| 77 | ); |
| 78 | } |
| 79 | |
| 80 | public function getDependentProperties(DependentPropertiesRepository $dependentPropertiesRepository): void |
| 81 | { |
| 82 | $property = $this->getProperty( |
| 83 | tao_helpers_Uri::decode( |
| 84 | $this->getGetParameter('propertyUri', '') |
| 85 | ) |
| 86 | ); |
| 87 | |
| 88 | $dependentProperties = $dependentPropertiesRepository->findAll( |
| 89 | new DependentPropertiesRepositoryContext([ |
| 90 | DependentPropertiesRepositoryContext::PARAM_PROPERTY => $property, |
| 91 | ]) |
| 92 | ); |
| 93 | |
| 94 | $this->setSuccessJsonResponse( |
| 95 | array_map( |
| 96 | static function (core_kernel_classes_Resource $property) { |
| 97 | return [ |
| 98 | 'label' => $property->getLabel(), |
| 99 | ]; |
| 100 | }, |
| 101 | $dependentProperties |
| 102 | ) |
| 103 | ); |
| 104 | } |
| 105 | |
| 106 | private function getRepository(): DependsOnPropertyRepositoryInterface |
| 107 | { |
| 108 | return $this->getPsrContainer()->get(DependsOnPropertyRepository::class); |
| 109 | } |
| 110 | } |