1
|
|
|
<?php |
2
|
|
|
/*************************************************************************************/ |
3
|
|
|
/* This file is part of the RewriteUrl module for Thelia. */ |
4
|
|
|
/* */ |
5
|
|
|
/* Copyright (c) OpenStudio */ |
6
|
|
|
/* email : [email protected] */ |
7
|
|
|
/* web : http://www.thelia.net */ |
8
|
|
|
/* */ |
9
|
|
|
/* For the full copyright and license information, please view the LICENSE.txt */ |
10
|
|
|
/* file that was distributed with this source code. */ |
11
|
|
|
/*************************************************************************************/ |
12
|
|
|
|
13
|
|
|
namespace RewriteUrl\Event; |
14
|
|
|
|
15
|
|
|
use RewriteUrl\Model\RewritingRedirectType; |
16
|
|
|
use Thelia\Core\Event\ActionEvent; |
17
|
|
|
use Thelia\Model\RewritingUrl; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Class RewriteUrlEvent |
21
|
|
|
* @package RewriteUrl\Event |
22
|
|
|
* @author Vincent Lopes <[email protected]> |
23
|
|
|
* @author Gilles Bourgeat <[email protected]> |
24
|
|
|
*/ |
25
|
|
|
class RewriteUrlEvent extends ActionEvent |
26
|
|
|
{ |
27
|
|
|
/** @var int|null */ |
28
|
|
|
protected $id; |
29
|
|
|
|
30
|
|
|
/** @var string */ |
31
|
|
|
protected $url; |
32
|
|
|
|
33
|
|
|
/** @var string */ |
34
|
|
|
protected $view; |
35
|
|
|
|
36
|
|
|
/** @var string */ |
37
|
|
|
protected $viewLocale; |
38
|
|
|
|
39
|
|
|
/** @var int|null */ |
40
|
|
|
protected $redirected; |
41
|
|
|
|
42
|
|
|
/** @var RewritingUrl */ |
43
|
|
|
private $rewritingUrl; |
44
|
|
|
|
45
|
|
|
/** @var RewritingRedirectType */ |
46
|
|
|
private $redirectType; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @param RewritingUrl $rewritingUrl |
50
|
|
|
* @param RewritingRedirectType $redirectType |
51
|
|
|
*/ |
52
|
|
|
public function __construct(RewritingUrl $rewritingUrl, RewritingRedirectType $redirectType = null) |
53
|
|
|
{ |
54
|
|
|
$this->id = $rewritingUrl->getId(); |
55
|
|
|
$this->url = $rewritingUrl->getUrl(); |
56
|
|
|
$this->view = $rewritingUrl->getView(); |
57
|
|
|
$this->viewLocale = $rewritingUrl->getViewLocale(); |
58
|
|
|
$this->redirected = $rewritingUrl->getRedirected(); |
59
|
|
|
$this->rewritingUrl = $rewritingUrl; |
60
|
|
|
$this->redirectType = $redirectType; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @return RewritingUrl |
65
|
|
|
*/ |
66
|
|
|
public function getRewritingUrl() |
67
|
|
|
{ |
68
|
|
|
return $this->rewritingUrl; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @return RewritingRedirectType |
73
|
|
|
*/ |
74
|
|
|
public function getRedirectType() |
75
|
|
|
{ |
76
|
|
|
return $this->redirectType; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @param int $id|null |
|
|
|
|
81
|
|
|
* @return $this |
82
|
|
|
*/ |
83
|
|
|
public function setId($id) |
84
|
|
|
{ |
85
|
|
|
$this->id = $id; |
86
|
|
|
|
87
|
|
|
return $this; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* @return int |
92
|
|
|
*/ |
93
|
|
|
public function getId() |
94
|
|
|
{ |
95
|
|
|
return $this->id; |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* @param array $parameters |
100
|
|
|
* @return $this |
101
|
|
|
*/ |
102
|
|
|
public function setParameters(array $parameters) |
103
|
|
|
{ |
104
|
|
|
$this->parameters = $parameters; |
105
|
|
|
|
106
|
|
|
return $this; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* @return array |
111
|
|
|
*/ |
112
|
|
|
public function getParameters() |
113
|
|
|
{ |
114
|
|
|
return $this->parameters; |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* @param boolean $propagationStopped |
119
|
|
|
* @return $this |
120
|
|
|
*/ |
121
|
|
|
public function setPropagationStopped($propagationStopped) |
122
|
|
|
{ |
123
|
|
|
$this->propagationStopped = boolval($propagationStopped); |
124
|
|
|
|
125
|
|
|
return $this; |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* @return boolean |
130
|
|
|
*/ |
131
|
|
|
public function getPropagationStopped() |
132
|
|
|
{ |
133
|
|
|
return $this->propagationStopped; |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
/** |
137
|
|
|
* @param null|int $redirected |
138
|
|
|
* @return $this |
139
|
|
|
*/ |
140
|
|
|
public function setRedirected($redirected) |
141
|
|
|
{ |
142
|
|
|
$this->redirected = $redirected; |
143
|
|
|
|
144
|
|
|
return $this; |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
/** |
148
|
|
|
* @return null|int |
149
|
|
|
*/ |
150
|
|
|
public function getRedirected() |
151
|
|
|
{ |
152
|
|
|
return $this->redirected; |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
/** |
156
|
|
|
* @param string $url |
157
|
|
|
* @return $this |
158
|
|
|
*/ |
159
|
|
|
public function setUrl($url) |
160
|
|
|
{ |
161
|
|
|
$this->url = $url; |
162
|
|
|
|
163
|
|
|
return $this; |
164
|
|
|
} |
165
|
|
|
|
166
|
|
|
/** |
167
|
|
|
* @return null|int |
168
|
|
|
*/ |
169
|
|
|
public function getUrl() |
170
|
|
|
{ |
171
|
|
|
return $this->url; |
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
/** |
175
|
|
|
* @param $view |
176
|
|
|
* @return $this |
177
|
|
|
*/ |
178
|
|
|
public function setView($view) |
179
|
|
|
{ |
180
|
|
|
$this->view = $view; |
181
|
|
|
|
182
|
|
|
return $this; |
183
|
|
|
} |
184
|
|
|
|
185
|
|
|
/** |
186
|
|
|
* @return null |
187
|
|
|
*/ |
188
|
|
|
public function getView() |
189
|
|
|
{ |
190
|
|
|
return $this->view; |
191
|
|
|
} |
192
|
|
|
|
193
|
|
|
/** |
194
|
|
|
* @param string $view_locale |
195
|
|
|
* @return $this |
196
|
|
|
*/ |
197
|
|
|
public function setViewLocale($view_locale) |
198
|
|
|
{ |
199
|
|
|
$this->viewLocale = $view_locale; |
200
|
|
|
|
201
|
|
|
return $this; |
202
|
|
|
} |
203
|
|
|
|
204
|
|
|
/** |
205
|
|
|
* @return null |
206
|
|
|
*/ |
207
|
|
|
public function getViewLocale() |
208
|
|
|
{ |
209
|
|
|
return $this->viewLocale; |
210
|
|
|
} |
211
|
|
|
} |
212
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.