Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
1 | <?php |
||
20 | class WidgetsController extends Controller |
||
|
|||
21 | { |
||
22 | /** |
||
23 | * @Route("/ckselecturl", name="KunstmaanNodeBundle_ckselecturl") |
||
24 | * @Template("KunstmaanNodeBundle:Widgets:selectLink.html.twig") |
||
25 | * |
||
26 | * @param \Symfony\Component\HttpFoundation\Request $request |
||
27 | * |
||
28 | * @return array |
||
29 | */ |
||
30 | View Code Duplication | public function ckSelectLinkAction(Request $request) |
|
38 | |||
39 | /** |
||
40 | * Select a link |
||
41 | * |
||
42 | * @Route("/selecturl", name="KunstmaanNodeBundle_selecturl") |
||
43 | * @Template("KunstmaanNodeBundle:Widgets:selectLink.html.twig") |
||
44 | * |
||
45 | * @param \Symfony\Component\HttpFoundation\Request $request |
||
46 | * |
||
47 | * @return array |
||
48 | */ |
||
49 | View Code Duplication | public function selectLinkAction(Request $request) |
|
57 | |||
58 | /** |
||
59 | * Select a link |
||
60 | * |
||
61 | * @Route("/select-nodes-lazy_search", name="KunstmaanNodeBundle_nodes_lazy_search") |
||
62 | * |
||
63 | * @param \Symfony\Component\HttpFoundation\Request $request |
||
64 | * |
||
65 | * @return JsonResponse |
||
66 | */ |
||
67 | public function selectNodesLazySearch(Request $request) |
||
94 | |||
95 | /** |
||
96 | * Select a link |
||
97 | * |
||
98 | * @Route("/select-nodes-lazy", name="KunstmaanNodeBundle_nodes_lazy") |
||
99 | * |
||
100 | * @param \Symfony\Component\HttpFoundation\Request $request |
||
101 | * |
||
102 | * @return JsonResponse |
||
103 | */ |
||
104 | public function selectNodesLazy(Request $request) |
||
129 | |||
130 | /** |
||
131 | * Get the parameters needed in the template. This is common for the |
||
132 | * default link chooser and the cke link chooser. |
||
133 | * |
||
134 | * @param \Symfony\Component\HttpFoundation\Request $request |
||
135 | * |
||
136 | * @return array |
||
137 | */ |
||
138 | private function getTemplateParameters(Request $request) |
||
160 | |||
161 | /** |
||
162 | * Determine if current node is a structure page. |
||
163 | * |
||
164 | * @param string $refEntityName |
||
165 | * |
||
166 | * @return bool |
||
167 | */ |
||
168 | protected function isStructurePage($refEntityName) |
||
169 | { |
||
170 | $structurePage = false; |
||
171 | if (class_exists($refEntityName)) { |
||
172 | $page = new $refEntityName(); |
||
173 | $structurePage = ($page instanceof AbstractStructurePage); |
||
174 | unset($page); |
||
175 | } |
||
176 | |||
177 | return $structurePage; |
||
178 | } |
||
179 | |||
180 | /** |
||
181 | * Determine if current node is a structure node. |
||
182 | * |
||
183 | * @param string $locale |
||
184 | * @param Node[]|ArrayCollection $rootNodes |
||
185 | * @param int $depth |
||
186 | * |
||
187 | * @return array |
||
188 | */ |
||
189 | protected function nodesToArray($locale, $rootNodes, $depth = 2) |
||
228 | } |
||
229 |
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.