This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Drupal\controller_annotations\Configuration; |
||
4 | |||
5 | use Symfony\Component\Routing\Route as RoutingRoute; |
||
6 | |||
7 | /** |
||
8 | * @Annotation |
||
9 | */ |
||
10 | class Title extends ConfigurationAnnotation implements RouteModifierMethodInterface, RouteModifierClassInterface |
||
11 | { |
||
12 | /** |
||
13 | * @var string |
||
14 | */ |
||
15 | protected $value; |
||
16 | |||
17 | /** |
||
18 | * @var array |
||
19 | */ |
||
20 | protected $arguments; |
||
21 | |||
22 | /** |
||
23 | * @var array |
||
24 | */ |
||
25 | protected $context; |
||
26 | |||
27 | /** |
||
28 | * @var string |
||
29 | */ |
||
30 | protected $callback; |
||
31 | |||
32 | /** |
||
33 | * @param $title |
||
34 | */ |
||
35 | 8 | public function setValue($title) |
|
36 | { |
||
37 | 8 | $this->setTitle($title); |
|
38 | 8 | } |
|
39 | |||
40 | /** |
||
41 | * @return bool |
||
42 | */ |
||
43 | 9 | public function hasTitle() |
|
44 | { |
||
45 | 9 | return !empty($this->value); |
|
46 | } |
||
47 | |||
48 | /** |
||
49 | * @return string |
||
50 | */ |
||
51 | 8 | public function getTitle() |
|
52 | { |
||
53 | 8 | return $this->value; |
|
54 | } |
||
55 | |||
56 | /** |
||
57 | * @param string $title |
||
58 | */ |
||
59 | 8 | public function setTitle($title) |
|
60 | { |
||
61 | 8 | $this->value = $title; |
|
62 | 8 | } |
|
63 | |||
64 | /** |
||
65 | * @return bool |
||
66 | */ |
||
67 | 9 | public function hasArguments() |
|
68 | { |
||
69 | 9 | return !empty($this->arguments); |
|
70 | } |
||
71 | |||
72 | /** |
||
73 | * @return array |
||
74 | */ |
||
75 | 8 | public function getArguments() |
|
76 | { |
||
77 | 8 | return $this->arguments; |
|
78 | } |
||
79 | |||
80 | /** |
||
81 | * @param array $arguments |
||
82 | */ |
||
83 | 8 | public function setArguments(array $arguments) |
|
84 | { |
||
85 | 8 | $this->arguments = $arguments; |
|
86 | 8 | } |
|
87 | |||
88 | /** |
||
89 | * @return bool |
||
90 | */ |
||
91 | 9 | public function hasContext() |
|
92 | { |
||
93 | 9 | return !empty($this->context); |
|
94 | } |
||
95 | |||
96 | /** |
||
97 | * @return array |
||
98 | */ |
||
99 | 1 | public function getContext() |
|
100 | { |
||
101 | 1 | return $this->context; |
|
102 | } |
||
103 | |||
104 | /** |
||
105 | * @param array $context |
||
106 | */ |
||
107 | 1 | public function setContext(array $context) |
|
108 | { |
||
109 | 1 | $this->context = $context; |
|
110 | 1 | } |
|
111 | |||
112 | /** |
||
113 | * @return bool |
||
114 | */ |
||
115 | 9 | public function hasCallback() |
|
116 | { |
||
117 | 9 | return !empty($this->callback); |
|
118 | } |
||
119 | |||
120 | /** |
||
121 | * @return string |
||
122 | */ |
||
123 | 9 | public function getCallback() |
|
124 | { |
||
125 | 9 | return $this->callback; |
|
126 | } |
||
127 | |||
128 | /** |
||
129 | * @param string $callback |
||
130 | */ |
||
131 | 9 | public function setCallback($callback) |
|
132 | { |
||
133 | 9 | $this->callback = $callback; |
|
134 | 9 | } |
|
135 | |||
136 | /** |
||
137 | * @return string |
||
138 | */ |
||
139 | 1 | public function getAliasName() |
|
140 | { |
||
141 | 1 | return 'title'; |
|
142 | } |
||
143 | |||
144 | /** |
||
145 | * @return bool |
||
146 | */ |
||
147 | 1 | public function allowArray() |
|
148 | { |
||
149 | 1 | return false; |
|
150 | } |
||
151 | |||
152 | /** |
||
153 | * @param RoutingRoute $route |
||
154 | * @param \ReflectionClass $class |
||
155 | * @param \ReflectionMethod $method |
||
156 | */ |
||
157 | 1 | public function modifyRouteClass(RoutingRoute $route, \ReflectionClass $class, \ReflectionMethod $method) |
|
158 | { |
||
159 | 1 | $this->modifyRoute($route, $class); |
|
160 | 1 | } |
|
161 | |||
162 | /** |
||
163 | * @param RoutingRoute $route |
||
164 | * @param \ReflectionClass $class |
||
165 | * @param \ReflectionMethod $method |
||
166 | */ |
||
167 | 8 | public function modifyRouteMethod(RoutingRoute $route, \ReflectionClass $class, \ReflectionMethod $method) |
|
168 | { |
||
169 | 8 | $this->modifyRoute($route, $class); |
|
170 | 8 | } |
|
171 | |||
172 | /** |
||
173 | * @param RoutingRoute $route |
||
174 | * @param \ReflectionClass $class |
||
175 | */ |
||
176 | 9 | protected function modifyRoute(RoutingRoute $route, \ReflectionClass $class) |
|
177 | { |
||
178 | 9 | if ($this->hasTitle()) { |
|
179 | 8 | $route->setDefault('_title', $this->getTitle()); |
|
180 | } |
||
181 | 9 | if ($this->hasArguments()) { |
|
182 | 8 | $route->setDefault('_title_arguments', $this->getArguments()); |
|
183 | } |
||
184 | 9 | if ($this->hasContext()) { |
|
185 | 1 | $route->setDefault('_title_context', $this->getContext()); |
|
186 | } |
||
187 | |||
188 | 9 | $this->registerCallback($route, $class); |
|
189 | 9 | } |
|
190 | |||
191 | /** |
||
192 | * @param RoutingRoute $route |
||
193 | * @param \ReflectionClass $class |
||
194 | */ |
||
195 | 9 | View Code Duplication | protected function registerCallback(RoutingRoute $route, \ReflectionClass $class) |
0 ignored issues
–
show
|
|||
196 | { |
||
197 | 9 | if ($this->hasCallback()) { |
|
198 | 9 | if (strpos($this->getCallback(), '::') === false && $class->hasMethod($this->getCallback())) { |
|
199 | 8 | $this->setCallback(sprintf('%s::%s', $class->getName(), $this->getCallback())); |
|
0 ignored issues
–
show
![]() |
|||
200 | } |
||
201 | 9 | $route->setDefault('_title_callback', $this->getCallback()); |
|
202 | } |
||
203 | 9 | } |
|
204 | } |
||
205 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.