|
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\Form\FormObject\Service; |
|
15
|
|
|
|
|
16
|
|
|
use Romm\Formz\Configuration\Form\Step\Step\Step; |
|
17
|
|
|
use Romm\Formz\Configuration\Form\Step\Step\StepDefinition; |
|
18
|
|
|
use Romm\Formz\Core\Core; |
|
19
|
|
|
use Romm\Formz\Form\FormObject\FormObject; |
|
20
|
|
|
use TYPO3\CMS\Extbase\Mvc\Web\Request; |
|
21
|
|
|
|
|
22
|
|
|
class FormObjectSteps |
|
23
|
|
|
{ |
|
24
|
|
|
/** |
|
25
|
|
|
* @var FormObject |
|
26
|
|
|
*/ |
|
27
|
|
|
protected $formObject; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @param FormObject $formObject |
|
31
|
|
|
*/ |
|
32
|
|
|
public function __construct(FormObject $formObject) |
|
33
|
|
|
{ |
|
34
|
|
|
$this->formObject = $formObject; |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* This function will search among the registered steps to find the one that |
|
39
|
|
|
* has the same controller parameters. |
|
40
|
|
|
* |
|
41
|
|
|
* It is also possible not to find any step, in this case `null` is |
|
42
|
|
|
* returned. |
|
43
|
|
|
* |
|
44
|
|
|
* @param Request $request |
|
45
|
|
|
* @return Step|null |
|
46
|
|
|
*/ |
|
47
|
|
|
public function getCurrentStep(Request $request) |
|
48
|
|
|
{ |
|
49
|
|
|
$configuration = $this->formObject->getConfiguration(); |
|
50
|
|
|
|
|
51
|
|
|
if (false === $configuration->hasSteps()) { |
|
52
|
|
|
return null; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
$currentStep = null; |
|
56
|
|
|
|
|
57
|
|
|
foreach ($configuration->getSteps()->getEntries() as $step) { |
|
58
|
|
|
$data = [ |
|
59
|
|
|
$step->getPageUid() => Core::get()->getPageController()->id, |
|
60
|
|
|
$step->getExtension() => $request->getControllerExtensionName(), |
|
61
|
|
|
$step->getController() => $request->getControllerName(), |
|
62
|
|
|
$step->getAction() => $request->getControllerActionName(), |
|
63
|
|
|
]; |
|
64
|
|
|
|
|
65
|
|
|
foreach ($data as $stepData => $requestData) { |
|
66
|
|
|
if (false === empty($stepData) |
|
67
|
|
|
&& $stepData !== $requestData |
|
68
|
|
|
) { |
|
69
|
|
|
continue 2; |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
if (null !== $currentStep) { |
|
74
|
|
|
throw new \Exception('todo'); // @todo |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
$currentStep = $step; |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
return $currentStep; |
|
81
|
|
|
} |
|
82
|
|
|
} |
|
83
|
|
|
|