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\Middleware\Request; |
15
|
|
|
|
16
|
|
|
use Romm\Formz\Middleware\Request\Exception\StopPropagationException; |
17
|
|
|
use TYPO3\CMS\Extbase\Mvc\Request; |
18
|
|
|
|
19
|
|
|
abstract class Dispatcher |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* @var Request |
23
|
|
|
*/ |
24
|
|
|
protected $request; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @var string |
28
|
|
|
*/ |
29
|
|
|
protected $action; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @var string |
33
|
|
|
*/ |
34
|
|
|
protected $controller; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @var string |
38
|
|
|
*/ |
39
|
|
|
protected $extension; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @var array |
43
|
|
|
*/ |
44
|
|
|
protected $arguments = []; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @param Request $request |
48
|
|
|
*/ |
49
|
|
|
final public function __construct(Request $request) |
50
|
|
|
{ |
51
|
|
|
$this->request = $request; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Dispatch implementation of this request dispatcher. |
56
|
|
|
* |
57
|
|
|
* @throws StopPropagationException |
58
|
|
|
* @return void |
59
|
|
|
*/ |
60
|
|
|
abstract public function dispatch(); |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @param string $action |
64
|
|
|
* @return $this |
65
|
|
|
*/ |
66
|
|
|
public function toAction($action) |
67
|
|
|
{ |
68
|
|
|
$this->action = $action; |
69
|
|
|
|
70
|
|
|
return $this; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* @param string $controller |
75
|
|
|
* @return $this |
76
|
|
|
*/ |
77
|
|
|
public function toController($controller) |
78
|
|
|
{ |
79
|
|
|
$this->controller = $controller; |
80
|
|
|
|
81
|
|
|
return $this; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @param string $extension |
86
|
|
|
* @return $this |
87
|
|
|
*/ |
88
|
|
|
public function toExtension($extension) |
89
|
|
|
{ |
90
|
|
|
$this->extension = $extension; |
91
|
|
|
|
92
|
|
|
return $this; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* @param array $arguments |
97
|
|
|
* @return $this |
98
|
|
|
*/ |
99
|
|
|
public function withArguments(array $arguments) |
100
|
|
|
{ |
101
|
|
|
$this->arguments = $arguments; |
102
|
|
|
|
103
|
|
|
return $this; |
104
|
|
|
} |
105
|
|
|
} |
106
|
|
|
|