1
|
|
|
<?php |
2
|
|
|
namespace keeko\core\package; |
3
|
|
|
|
4
|
|
|
use keeko\core\kernel\KernelTargetInterface; |
5
|
|
|
use keeko\core\kernel\Page; |
6
|
|
|
use keeko\core\model\Application; |
7
|
|
|
use keeko\core\model\Localization; |
8
|
|
|
use keeko\core\service\ServiceContainer; |
9
|
|
|
use keeko\core\utils\TwigRenderTrait; |
10
|
|
|
use keeko\core\utils\TwigTrait; |
11
|
|
|
use Symfony\Component\HttpFoundation\Request; |
12
|
|
|
|
13
|
|
|
abstract class AbstractApplication implements KernelTargetInterface { |
14
|
|
|
|
15
|
|
|
use TwigTrait; |
16
|
|
|
use TwigRenderTrait; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* @var Application |
20
|
|
|
*/ |
21
|
|
|
protected $model; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @var Localization |
25
|
|
|
*/ |
26
|
|
|
protected $localization; |
27
|
|
|
|
28
|
|
|
protected $rootUrl; |
29
|
|
|
|
30
|
|
|
protected $appPath; |
31
|
|
|
|
32
|
|
|
protected $destinationPath; |
33
|
|
|
|
34
|
|
|
protected $appUrl; |
35
|
|
|
|
36
|
|
|
/** @var ServiceContainer */ |
37
|
|
|
protected $service; |
38
|
|
|
|
39
|
|
|
/** @var Page */ |
40
|
|
|
protected $page; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Creates a new Keeko Application |
44
|
|
|
*/ |
45
|
|
|
public function __construct(Application $model, ServiceContainer $service) { |
46
|
|
|
$this->model = $model; |
|
|
|
|
47
|
|
|
$this->service = $service; |
48
|
|
|
$this->page = new Page(); |
|
|
|
|
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Returns the applications name |
53
|
|
|
* |
54
|
|
|
* @return string |
55
|
|
|
*/ |
56
|
|
|
public function getName() { |
57
|
|
|
return $this->model->getName(); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* Returns the applications canonical name |
62
|
|
|
* |
63
|
|
|
* @return string |
64
|
|
|
*/ |
65
|
|
|
public function getCanonicalName() { |
66
|
|
|
return str_replace('/', '.', $this->model->getName()); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* Returns the applications title |
71
|
|
|
* |
72
|
|
|
* @return string |
73
|
|
|
*/ |
74
|
|
|
public function getTitle() { |
75
|
|
|
return $this->model->getTitle(); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* Returns the service container |
80
|
|
|
* |
81
|
|
|
* @return ServiceContainer |
82
|
|
|
*/ |
83
|
|
|
public function getServiceContainer() { |
84
|
|
|
return $this->service; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @return Page |
89
|
|
|
*/ |
90
|
|
|
public function getPage() { |
91
|
|
|
return $this->page; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* Returns the associated application model |
96
|
|
|
* |
97
|
|
|
* @return Application |
98
|
|
|
*/ |
99
|
|
|
public function getModel() { |
100
|
|
|
return $this->model; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
public function setAppPath($prefix) { |
104
|
|
|
$this->appPath = $prefix; |
105
|
|
|
$this->updateAppUrl(); |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
public function getAppPath() { |
|
|
|
|
109
|
|
|
return $this->appPath; |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
public function setRootUrl($root) { |
113
|
|
|
$this->rootUrl = $root; |
114
|
|
|
$this->updateAppUrl(); |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
public function getRootUrl() { |
|
|
|
|
118
|
|
|
return $this->rootUrl; |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
private function updateAppUrl() { |
122
|
|
|
$this->appUrl = $this->rootUrl . $this->appPath; |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
public function getAppUrl() { |
126
|
|
|
return $this->appUrl; |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
public function setDestinationPath($destination) { |
130
|
|
|
$this->destinationPath = $destination; |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
public function getDestinationPath() { |
|
|
|
|
134
|
|
|
return $this->destinationPath; |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
public function getTargetPath() { |
|
|
|
|
138
|
|
|
return $this->destinationPath; |
139
|
|
|
} |
140
|
|
|
|
141
|
|
|
public function getTailPath() { |
|
|
|
|
142
|
|
|
return $this->destinationPath; |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
public function setLocalization(Localization $localization) { |
146
|
|
|
$this->localization = $localization; |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
/** |
150
|
|
|
* |
151
|
|
|
* @return Localization |
152
|
|
|
*/ |
153
|
|
|
public function getLocalization() { |
154
|
|
|
return $this->localization; |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
public function getTwig() { |
|
|
|
|
158
|
|
|
return $this->getRawTwig(sprintf('%s/%s/templates/', KEEKO_PATH_APPS, $this->model->getName())); |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
protected function runAction(AbstractAction $action, Request $request) { |
|
|
|
|
162
|
|
|
$runner = $this->getServiceContainer()->getRunner(); |
|
|
|
|
163
|
|
|
return $runner->run($action, $request); |
164
|
|
|
} |
165
|
|
|
|
166
|
|
|
abstract public function run(Request $request); |
167
|
|
|
|
168
|
|
|
} |
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.
To visualize
will produce issues in the first and second line, while this second example
will produce no issues.