*/ declare(strict_types=1); use GuzzleHttp\Psr7\ServerRequest; use oat\generis\model\OntologyAwareTrait; use oat\tao\model\http\HttpJsonResponseTrait; use oat\tao\model\Lists\Business\Service\ValueCollectionService; use oat\tao\model\Lists\DataAccess\Repository\DependsOnPropertyRepository; use oat\tao\model\Lists\DataAccess\Repository\DependentPropertiesRepository; use oat\tao\model\Lists\Business\Domain\DependentPropertiesRepositoryContext; use oat\tao\model\Lists\Presentation\Web\RequestHandler\ValueCollectionSearchRequestHandler; class tao_actions_PropertyValues extends tao_actions_CommonModule { use HttpJsonResponseTrait; use OntologyAwareTrait; public function get( ServerRequest $request, ValueCollectionSearchRequestHandler $valueCollectionSearchRequestHandler, ValueCollectionService $valueCollectionService ): void { $this->setSuccessJsonResponse( $valueCollectionService->findAll( $valueCollectionSearchRequestHandler->handle($request) ) ); } public function getDependOnPropertyList(): void { $property = $this->hasGetParameter('property_uri') ? $this->getProperty(tao_helpers_Uri::decode($this->getGetParameter('property_uri'))) : null; $class = $this->hasGetParameter('class_uri') ? $this->getClass(tao_helpers_Uri::decode($this->getGetParameter('class_uri'))) : null; $this->setSuccessJsonResponse( $this->getRepository()->findAll( [ 'property' => $property, 'class' => $class, 'listUri' => $this->getProperty(tao_helpers_Uri::decode($this->getGetParameter('list_uri')))->getUri() ] ) ); } public function getDependentProperties(DependentPropertiesRepository $dependentPropertiesRepository): void { $property = $this->getProperty( tao_helpers_Uri::decode( $this->getGetParameter('propertyUri', '') ) ); $dependentProperties = $dependentPropertiesRepository->findAll( new DependentPropertiesRepositoryContext([ DependentPropertiesRepositoryContext::PARAM_PROPERTY => $property, ]) ); $this->setSuccessJsonResponse( array_map( static function (core_kernel_classes_Resource $property) { return [ 'label' => $property->getLabel(), ]; }, $dependentProperties ) ); } private function getRepository(): DependsOnPropertyRepository { return $this->getServiceLocator()->get(DependsOnPropertyRepository::class); } }