1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* 2017 Romain CANON <[email protected]> |
4
|
|
|
* |
5
|
|
|
* This file is part of the TYPO3 FormZ project. |
6
|
|
|
* It is free software; you can redistribute it and/or modify it |
7
|
|
|
* under the terms of the GNU General Public License, either |
8
|
|
|
* version 3 of the License, or any later version. |
9
|
|
|
* |
10
|
|
|
* For the full copyright and license information, see: |
11
|
|
|
* http://www.gnu.org/licenses/gpl-3.0.html |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace Romm\Formz\Service; |
15
|
|
|
|
16
|
|
|
use Romm\Formz\Exceptions\EntryNotFoundException; |
17
|
|
|
use Romm\Formz\Service\Traits\ExtendedFacadeInstanceTrait; |
18
|
|
|
use TYPO3\CMS\Core\SingletonInterface; |
19
|
|
|
use TYPO3\CMS\Extbase\Reflection\ReflectionService; |
20
|
|
|
|
21
|
|
|
class ControllerService implements SingletonInterface |
22
|
|
|
{ |
23
|
|
|
use ExtendedFacadeInstanceTrait; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @var ReflectionService |
27
|
|
|
*/ |
28
|
|
|
protected $reflectionService; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @param string $controllerName |
32
|
|
|
* @param string $actionName |
33
|
|
|
* @return array |
34
|
|
|
*/ |
35
|
|
|
public function getControllerActionParameters($controllerName, $actionName) |
36
|
|
|
{ |
37
|
|
|
return $this->reflectionService->getMethodParameters($controllerName, $actionName . 'Action'); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @param string $controllerName |
42
|
|
|
* @param string $actionName |
43
|
|
|
* @param string $formName |
44
|
|
|
* @return string |
45
|
|
|
* @throws EntryNotFoundException |
46
|
|
|
*/ |
47
|
|
|
public function getFormClassNameFromControllerAction($controllerName, $actionName, $formName) |
48
|
|
|
{ |
49
|
|
|
$methodParameters = $this->getControllerActionParameters($controllerName, $actionName); |
50
|
|
|
|
51
|
|
|
if (false === isset($methodParameters[$formName])) { |
52
|
|
|
throw EntryNotFoundException::controllerServiceActionFormArgumentMissing($controllerName, $actionName, $formName); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
return $methodParameters[$formName]['type']; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @param ReflectionService $reflectionService |
60
|
|
|
*/ |
61
|
|
|
public function injectReflectionService(ReflectionService $reflectionService) |
62
|
|
|
{ |
63
|
|
|
$this->reflectionService = $reflectionService; |
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
|