Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 14 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| tao_actions_Security | |
0.00% |
0 / 14 |
|
0.00% |
0 / 2 |
20 | |
0.00% |
0 / 1 |
| initialize | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| index | |
0.00% |
0 / 12 |
|
0.00% |
0 / 1 |
12 | |||
| 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 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT); |
| 19 | */ |
| 20 | |
| 21 | use oat\tao\model\security\Business\Contract\SecuritySettingsRepositoryInterface; |
| 22 | use tao_helpers_form_FormContainer as FormContainer; |
| 23 | |
| 24 | /** |
| 25 | * Class Security |
| 26 | * |
| 27 | * @author Martijn Swinkels <m.swinkels@taotesting.com> |
| 28 | */ |
| 29 | class tao_actions_Security extends tao_actions_CommonModule |
| 30 | { |
| 31 | /** @var SecuritySettingsRepositoryInterface */ |
| 32 | private $repository; |
| 33 | |
| 34 | /** |
| 35 | * @inheritDoc |
| 36 | */ |
| 37 | public function initialize(): void |
| 38 | { |
| 39 | parent::initialize(); |
| 40 | |
| 41 | $this->repository = $this->getServiceLocator()->get(SecuritySettingsRepositoryInterface::class); |
| 42 | } |
| 43 | |
| 44 | public function index(): void |
| 45 | { |
| 46 | $this->setView('security/view.tpl'); |
| 47 | |
| 48 | $formFactory = new tao_actions_form_CspHeader( |
| 49 | [tao_actions_form_CspHeader::SETTINGS_DATA => $this->repository->findAll()], |
| 50 | [FormContainer::CSRF_PROTECTION_OPTION => true] |
| 51 | ); |
| 52 | |
| 53 | $cspHeaderForm = $formFactory->getForm(); |
| 54 | |
| 55 | if ($cspHeaderForm->isSubmited() && $cspHeaderForm->isValid()) { |
| 56 | $this->repository->persist( |
| 57 | $formFactory->getSettings() |
| 58 | ); |
| 59 | |
| 60 | $this->setData('cspHeaderFormSuccess', __('CSP Header settings were saved successfully!')); |
| 61 | } |
| 62 | |
| 63 | $this->setData('cspHeaderForm', $cspHeaderForm->render()); |
| 64 | } |
| 65 | } |