Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 12 |
|
0.00% |
0 / 7 |
CRAP | |
0.00% |
0 / 1 |
| ProviderAdmin | |
0.00% |
0 / 12 |
|
0.00% |
0 / 7 |
72 | |
0.00% |
0 / 1 |
| getExcludedProperties | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getFeatureFlagFormPropertyMapper | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getClassService | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getExtraValidationRules | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getLtiVersion | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
6 | |||
| getValidationFactory | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getConfigurationMapper | |
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) 2019-2020 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT); |
| 19 | */ |
| 20 | |
| 21 | declare(strict_types=1); |
| 22 | |
| 23 | namespace oat\taoLti\controller; |
| 24 | |
| 25 | use oat\taoLti\models\classes\LtiProvider\LtiProviderFieldsMapper; |
| 26 | use oat\taoLti\models\classes\LtiProvider\FeatureFlagFormPropertyMapper; |
| 27 | use oat\taoLti\models\classes\LtiProvider\RdfLtiProviderRepository; |
| 28 | use oat\taoLti\models\classes\LtiProvider\Validation\ValidatorsFactory; |
| 29 | use tao_actions_SaSModule; |
| 30 | use tao_helpers_Uri; |
| 31 | |
| 32 | /** |
| 33 | * This controller allows the adding and deletion of LTI Oauth Providers |
| 34 | * |
| 35 | * @license GPLv2 http://www.opensource.org/licenses/gpl-2.0.php |
| 36 | */ |
| 37 | class ProviderAdmin extends tao_actions_SaSModule |
| 38 | { |
| 39 | protected function getExcludedProperties(): array |
| 40 | { |
| 41 | return $this->getFeatureFlagFormPropertyMapper()->getExcludedProperties(); |
| 42 | } |
| 43 | |
| 44 | private function getFeatureFlagFormPropertyMapper(): FeatureFlagFormPropertyMapper |
| 45 | { |
| 46 | return $this->getServiceLocator()->get(FeatureFlagFormPropertyMapper::class); |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * (non-PHPdoc) |
| 51 | * |
| 52 | * @see \tao_actions_RdfController::getClassService() |
| 53 | * @security("hide"); |
| 54 | */ |
| 55 | public function getClassService() |
| 56 | { |
| 57 | return $this->getServiceLocator()->get(RdfLtiProviderRepository::class); |
| 58 | } |
| 59 | |
| 60 | protected function getExtraValidationRules(): array |
| 61 | { |
| 62 | return $this->getValidationFactory()->createFormValidators($this->getLtiVersion()); |
| 63 | } |
| 64 | |
| 65 | private function getLtiVersion(): string |
| 66 | { |
| 67 | $body = $this->getPsrRequest()->getParsedBody(); |
| 68 | $rawLtiVersion = trim($body[tao_helpers_Uri::encode(RdfLtiProviderRepository::LTI_VERSION)] ?? ''); |
| 69 | $ltiVersion = empty($rawLtiVersion) |
| 70 | ? RdfLtiProviderRepository::DEFAULT_LTI_VERSION |
| 71 | : tao_helpers_Uri::decode($rawLtiVersion); |
| 72 | |
| 73 | return $this->getConfigurationMapper()->map($ltiVersion); |
| 74 | } |
| 75 | |
| 76 | private function getValidationFactory(): ValidatorsFactory |
| 77 | { |
| 78 | /** @noinspection PhpIncompatibleReturnTypeInspection */ |
| 79 | return $this->getServiceLocator()->get(ValidatorsFactory::class); |
| 80 | } |
| 81 | |
| 82 | private function getConfigurationMapper(): LtiProviderFieldsMapper |
| 83 | { |
| 84 | /** @noinspection PhpIncompatibleReturnTypeInspection */ |
| 85 | return $this->getServiceLocator()->get(LtiProviderFieldsMapper::class); |
| 86 | } |
| 87 | } |