Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 12
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
tao_actions_ClassMetadata
0.00% covered (danger)
0.00%
0 / 12
0.00% covered (danger)
0.00%
0 / 2
6
0.00% covered (danger)
0.00%
0 / 1
 get
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
2
 getWithMapping
0.00% covered (danger)
0.00%
0 / 9
0.00% covered (danger)
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 */
21
22declare(strict_types=1);
23
24use GuzzleHttp\Psr7\ServerRequest;
25use oat\tao\model\http\HttpJsonResponseTrait;
26use oat\tao\model\Lists\Business\Domain\ClassInformation;
27use oat\tao\model\Lists\Business\Service\ClassMetadataSearcherProxy;
28use oat\tao\model\Lists\Business\Service\GetClassMetadataValuesService;
29use oat\tao\model\Lists\Presentation\Web\RequestHandler\ClassMetadataSearchRequestHandler;
30
31class tao_actions_ClassMetadata extends tao_actions_CommonModule
32{
33    use HttpJsonResponseTrait;
34
35    /**
36     * @deprecated $this->getWithMapping should be used
37     */
38    public function get(
39        ServerRequest $request,
40        ClassMetadataSearchRequestHandler $classMetadataSearchRequestHandler,
41        ClassMetadataSearcherProxy $classMetadataSearcher
42    ): void {
43        $this->setSuccessJsonResponse(
44            $classMetadataSearcher->findAll($classMetadataSearchRequestHandler->handle($request))
45        );
46    }
47
48    public function getWithMapping(
49        ServerRequest $request,
50        ClassMetadataSearchRequestHandler $classMetadataSearchRequestHandler,
51        ClassMetadataSearcherProxy $classMetadataSearcher
52    ): void {
53        $this->setSuccessJsonResponse(
54            new ClassInformation(
55                $classMetadataSearcher->findAll($classMetadataSearchRequestHandler->handle($request)),
56                [
57                    GetClassMetadataValuesService::DATA_TYPE_LIST => 'uri',
58                    GetClassMetadataValuesService::DATA_TYPE_TEXT => 'label'
59                ]
60            )
61        );
62    }
63}