|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the Tadcka package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Tadas Gliaubicas <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Tadcka\Component\Routing\Model; |
|
13
|
|
|
|
|
14
|
|
|
use Symfony\Component\Routing\Route as SymfonyRoute; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* @author Tadas Gliaubicas <[email protected]> |
|
18
|
|
|
* |
|
19
|
|
|
* @since 7/1/14 10:54 PM |
|
20
|
|
|
*/ |
|
21
|
|
|
abstract class Route extends SymfonyRoute implements RouteInterface |
|
22
|
|
|
{ |
|
23
|
|
|
/** |
|
24
|
|
|
* @var string |
|
25
|
|
|
*/ |
|
26
|
|
|
protected $name; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @var string |
|
30
|
|
|
*/ |
|
31
|
|
|
protected $routePattern; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* @var string |
|
35
|
|
|
*/ |
|
36
|
|
|
protected $prefix; |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* @var bool |
|
40
|
|
|
*/ |
|
41
|
|
|
protected $recompile = false; |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* @var bool |
|
45
|
|
|
*/ |
|
46
|
|
|
protected $visible = false; |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* Constructor. |
|
50
|
|
|
*/ |
|
51
|
3 |
|
public function __construct() |
|
52
|
|
|
{ |
|
53
|
3 |
|
parent::__construct($this->routePattern); |
|
54
|
|
|
|
|
55
|
3 |
|
$this->setDefaults(array()); |
|
56
|
3 |
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* {@inheritdoc} |
|
60
|
|
|
*/ |
|
61
|
|
|
public function getContent() |
|
62
|
|
|
{ |
|
63
|
|
|
// TODO: Implement getContent() method. |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* {@inheritdoc} |
|
68
|
|
|
*/ |
|
69
|
|
|
public function getRouteKey() |
|
70
|
|
|
{ |
|
71
|
|
|
return $this->getId(); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* {@inheritdoc} |
|
76
|
|
|
*/ |
|
77
|
|
|
public function addLocale($defaultLocale, array $requirements) |
|
78
|
|
|
{ |
|
79
|
|
|
$this->prefix = '/{_locale}'; |
|
80
|
|
|
|
|
81
|
|
|
$this->setDefault('_locale', $defaultLocale); |
|
82
|
|
|
$this->addRequirements(array('_locale' => implode('|', $requirements))); |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
/** |
|
86
|
|
|
* {@inheritdoc} |
|
87
|
|
|
*/ |
|
88
|
1 |
|
public function setName($name) |
|
89
|
|
|
{ |
|
90
|
1 |
|
$this->name = $name; |
|
91
|
|
|
|
|
92
|
1 |
|
return $this; |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
/** |
|
96
|
|
|
* {@inheritdoc} |
|
97
|
|
|
*/ |
|
98
|
3 |
|
public function getName() |
|
99
|
|
|
{ |
|
100
|
3 |
|
return $this->name; |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
/** |
|
104
|
|
|
* {@inheritdoc} |
|
105
|
|
|
*/ |
|
106
|
2 |
|
public function setRoutePattern($routePattern) |
|
107
|
|
|
{ |
|
108
|
2 |
|
$this->routePattern = '/' . ltrim(trim($routePattern), '/'); |
|
109
|
2 |
|
$this->setPath($this->routePattern); |
|
110
|
2 |
|
$this->recompile = true; |
|
111
|
|
|
|
|
112
|
2 |
|
return $this; |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
/** |
|
116
|
|
|
* {@inheritDoc} |
|
117
|
|
|
*/ |
|
118
|
2 |
|
public function getRoutePattern() |
|
119
|
|
|
{ |
|
120
|
2 |
|
return $this->routePattern; |
|
121
|
|
|
} |
|
122
|
|
|
|
|
123
|
|
|
/** |
|
124
|
|
|
* {@inheritDoc} |
|
125
|
|
|
*/ |
|
126
|
|
|
public function getPath() |
|
127
|
|
|
{ |
|
128
|
|
|
return $this->prefix . $this->getRoutePattern(); |
|
129
|
|
|
} |
|
130
|
|
|
|
|
131
|
|
|
/** |
|
132
|
|
|
* {@inheritdoc} |
|
133
|
|
|
*/ |
|
134
|
|
|
public function setPrefix($prefix) |
|
135
|
|
|
{ |
|
136
|
|
|
$this->prefix = $prefix; |
|
137
|
|
|
|
|
138
|
|
|
return $this; |
|
139
|
|
|
} |
|
140
|
|
|
|
|
141
|
|
|
/** |
|
142
|
|
|
* {@inheritdoc} |
|
143
|
|
|
*/ |
|
144
|
|
|
public function getPrefix() |
|
145
|
|
|
{ |
|
146
|
|
|
return $this->prefix; |
|
147
|
|
|
} |
|
148
|
|
|
|
|
149
|
|
|
/** |
|
150
|
|
|
* {@inheritdoc} |
|
151
|
|
|
*/ |
|
152
|
|
|
public function setVisible($visible) |
|
153
|
|
|
{ |
|
154
|
|
|
$this->visible = $visible; |
|
155
|
|
|
} |
|
156
|
|
|
|
|
157
|
|
|
/** |
|
158
|
|
|
* {@inheritdoc} |
|
159
|
|
|
*/ |
|
160
|
|
|
public function isVisible() |
|
161
|
|
|
{ |
|
162
|
|
|
return $this->visible; |
|
163
|
|
|
} |
|
164
|
|
|
|
|
165
|
|
|
/** |
|
166
|
|
|
* {@inheritDoc} |
|
167
|
|
|
*/ |
|
168
|
|
|
public function compile() |
|
169
|
|
|
{ |
|
170
|
|
|
if ($this->recompile) { |
|
171
|
|
|
parent::setPath($this->getPath()); |
|
|
|
|
|
|
172
|
|
|
} |
|
173
|
|
|
|
|
174
|
|
|
return parent::compile(); |
|
175
|
|
|
} |
|
176
|
|
|
|
|
177
|
|
|
/** |
|
178
|
|
|
* @deprecated |
|
179
|
|
|
*/ |
|
180
|
|
|
public function getPattern() |
|
181
|
|
|
{ |
|
182
|
|
|
return $this->getPath(); |
|
183
|
|
|
} |
|
184
|
|
|
} |
|
185
|
|
|
|
This check looks for a call to a parent method whose name is different than the method from which it is called.
Consider the following code:
The
getFirstName()method in theSoncalls the wrong method in the parent class.