1 | <?php |
||
2 | declare(strict_types=1); |
||
3 | |||
4 | /* |
||
5 | * Copyright (C) |
||
6 | * Nathan Boiron <[email protected]> |
||
7 | * Romain Canon <[email protected]> |
||
8 | * |
||
9 | * This file is part of the TYPO3 NotiZ project. |
||
10 | * It is free software; you can redistribute it and/or modify it |
||
11 | * under the terms of the GNU General Public License, either |
||
12 | * version 3 of the License, or any later version. |
||
13 | * |
||
14 | * For the full copyright and license information, see: |
||
15 | * http://www.gnu.org/licenses/gpl-3.0.html |
||
16 | */ |
||
17 | |||
18 | namespace CuyZ\Notiz\Controller\Backend; |
||
19 | |||
20 | use CuyZ\Notiz\Backend\Module\AdministrationModuleHandler; |
||
21 | use CuyZ\Notiz\Controller\Backend\Administration\ShowExceptionController; |
||
22 | use CuyZ\Notiz\Controller\Backend\Administration\IndexController; |
||
23 | use CuyZ\Notiz\Controller\Backend\Administration\ShowDefinitionController; |
||
24 | use CuyZ\Notiz\Core\Definition\DefinitionService; |
||
25 | use CuyZ\Notiz\Core\Definition\Tree\Definition; |
||
26 | use CuyZ\Notiz\Service\LocalizationService; |
||
27 | use CuyZ\Notiz\Service\ViewService; |
||
28 | use TYPO3\CMS\Core\Messaging\AbstractMessage; |
||
29 | use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; |
||
0 ignored issues
–
show
|
|||
30 | use TYPO3\CMS\Extbase\Mvc\View\ViewInterface; |
||
0 ignored issues
–
show
The type
TYPO3\CMS\Extbase\Mvc\View\ViewInterface was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
31 | |||
32 | abstract class BackendController extends ActionController |
||
33 | { |
||
34 | /** |
||
35 | * @var DefinitionService |
||
36 | */ |
||
37 | protected $definitionService; |
||
38 | |||
39 | /** |
||
40 | * @var AdministrationModuleHandler |
||
41 | */ |
||
42 | protected $administrationModuleHandler; |
||
43 | |||
44 | /** |
||
45 | * @var ViewService |
||
46 | */ |
||
47 | protected $viewService; |
||
48 | |||
49 | /** |
||
50 | * Checking if the definition contains errors. |
||
51 | */ |
||
52 | public function initializeAction() |
||
53 | { |
||
54 | $this->checkDefinitionError(); |
||
55 | } |
||
56 | |||
57 | /** |
||
58 | * @param ViewInterface $view |
||
59 | */ |
||
60 | public function initializeView(ViewInterface $view) |
||
61 | { |
||
62 | if (!$this->definitionService->getValidationResult()->hasErrors()) { |
||
63 | $this->view->assign('definition', $this->getDefinition()); |
||
64 | } |
||
65 | |||
66 | $view->assignMultiple([ |
||
67 | 'result' => $this->definitionService->getValidationResult(), |
||
68 | 'request' => $this->request, |
||
69 | 'menu' => $this->getMenu(), |
||
70 | ]); |
||
71 | } |
||
72 | |||
73 | /** |
||
74 | * Must return a menu identifier. You should use a constant of the following |
||
75 | * interface: @see \CuyZ\Notiz\Controller\Backend\Menu |
||
76 | * |
||
77 | * @return string |
||
78 | */ |
||
79 | abstract protected function getMenu(): string; |
||
80 | |||
81 | /** |
||
82 | * If the definition contain errors, the request is forwarded. If the user |
||
83 | * is an administrator the administration module is shown, otherwise an |
||
84 | * error message is shown. |
||
85 | */ |
||
86 | protected function checkDefinitionError() |
||
87 | { |
||
88 | if (!$this->definitionService->getValidationResult()->hasErrors()) { |
||
89 | return; |
||
90 | } |
||
91 | |||
92 | if (IndexController::class === $this->request->getControllerObjectName() |
||
93 | || ShowDefinitionController::class === $this->request->getControllerObjectName() |
||
94 | || ShowExceptionController::class === $this->request->getControllerObjectName() |
||
95 | ) { |
||
96 | return; |
||
97 | } |
||
98 | |||
99 | if ($this->administrationModuleHandler->canBeAccessed()) { |
||
100 | $this->redirectToUri((string)$this->administrationModuleHandler->getUriBuilder()->build()); |
||
101 | } |
||
102 | |||
103 | if ('definitionError' !== $this->request->getControllerActionName()) { |
||
104 | $this->forward('definitionError'); |
||
105 | } |
||
106 | } |
||
107 | |||
108 | /** |
||
109 | * Action called when an error was found during definition being built (if |
||
110 | * the user is not an administrator). |
||
111 | */ |
||
112 | public function definitionErrorAction() |
||
113 | { |
||
114 | return $this->viewService->getStandaloneView('Backend/DefinitionError')->render(); |
||
115 | } |
||
116 | |||
117 | /** |
||
118 | * @param string $key |
||
119 | * @param mixed ...$arguments |
||
120 | */ |
||
121 | protected function addErrorMessage(string $key, ...$arguments) |
||
122 | { |
||
123 | $this->addFlashMessage( |
||
124 | LocalizationService::localize($key, $arguments), |
||
125 | '', |
||
126 | AbstractMessage::ERROR |
||
127 | ); |
||
128 | } |
||
129 | |||
130 | /** |
||
131 | * @return Definition |
||
132 | */ |
||
133 | protected function getDefinition(): Definition |
||
134 | { |
||
135 | return $this->definitionService->getDefinition(); |
||
136 | } |
||
137 | |||
138 | /** |
||
139 | * @param DefinitionService $definitionService |
||
140 | */ |
||
141 | public function injectDefinitionService(DefinitionService $definitionService) |
||
142 | { |
||
143 | $this->definitionService = $definitionService; |
||
144 | } |
||
145 | |||
146 | /** |
||
147 | * @param AdministrationModuleHandler $administrationModuleHandler |
||
148 | */ |
||
149 | public function injectAdministrationModuleHandler(AdministrationModuleHandler $administrationModuleHandler) |
||
150 | { |
||
151 | $this->administrationModuleHandler = $administrationModuleHandler; |
||
152 | } |
||
153 | |||
154 | /** |
||
155 | * @param ViewService $viewService |
||
156 | */ |
||
157 | public function injectViewService(ViewService $viewService) |
||
158 | { |
||
159 | $this->viewService = $viewService; |
||
160 | } |
||
161 | } |
||
162 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths