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 | /* |
||
4 | * This file is part of the Stinger Soft Platform package. |
||
5 | * |
||
6 | * (c) Oliver Kotte <[email protected]> |
||
7 | * (c) Florian Meyer <[email protected]> |
||
8 | * |
||
9 | * For the full copyright and license information, please view the LICENSE |
||
10 | * file that was distributed with this source code. |
||
11 | */ |
||
12 | namespace StingerSoft\PlatformBundle\Controller; |
||
13 | |||
14 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
||
15 | use Symfony\Component\Stopwatch\Stopwatch; |
||
16 | use Symfony\Component\Translation\TranslatorInterface; |
||
17 | use Doctrine\Common\Persistence\ObjectRepository; |
||
18 | |||
19 | class BaseController extends Controller { |
||
20 | |||
21 | /** |
||
22 | * Returns the default locale for the system |
||
23 | * |
||
24 | * @return string |
||
25 | */ |
||
26 | protected function getDefaultLocale() { |
||
27 | return 'en'; |
||
28 | } |
||
29 | |||
30 | /** |
||
31 | * Returns all available (i.e. |
||
32 | * configured) locales of the system |
||
33 | * |
||
34 | * @return string[] |
||
35 | */ |
||
36 | protected function getLocales() { |
||
37 | return array( |
||
38 | 'en' |
||
39 | ); |
||
40 | } |
||
41 | |||
42 | /** |
||
43 | * Proxy to use the transChoice method of the translator |
||
44 | * |
||
45 | * @see TranslatorInterface::transChoice() |
||
46 | * |
||
47 | * @param string $id |
||
48 | * @param int $number |
||
49 | * @param array $parameters |
||
50 | * @param string $domain |
||
0 ignored issues
–
show
|
|||
51 | * @param string $locale |
||
0 ignored issues
–
show
Should the type for parameter
$locale not be string|null ?
This check looks for It makes a suggestion as to what type it considers more descriptive. Most often this is a case of a parameter that can be null in addition to its declared types. ![]() |
|||
52 | * @return string |
||
53 | */ |
||
54 | View Code Duplication | protected function transChoice($id, $number, array $parameters = array(), $domain = null, $locale = null) { |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
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. ![]() |
|||
55 | /** |
||
56 | * |
||
57 | * @var TranslatorInterface $translator |
||
58 | */ |
||
59 | $translator = $this->getTranslator(); |
||
60 | return $translator->transChoice($id, $number, $parameters, $domain, $locale); |
||
61 | } |
||
62 | |||
63 | /** |
||
64 | * Proxy to use the transChoice method of the translator |
||
65 | * |
||
66 | * @see TranslatorInterface::trans() |
||
67 | * |
||
68 | * @param string $id |
||
69 | * @param array $parameters |
||
70 | * @param string $domain |
||
0 ignored issues
–
show
Should the type for parameter
$domain not be string|null ?
This check looks for It makes a suggestion as to what type it considers more descriptive. Most often this is a case of a parameter that can be null in addition to its declared types. ![]() |
|||
71 | * @param string $locale |
||
0 ignored issues
–
show
Should the type for parameter
$locale not be string|null ?
This check looks for It makes a suggestion as to what type it considers more descriptive. Most often this is a case of a parameter that can be null in addition to its declared types. ![]() |
|||
72 | * @return string |
||
73 | */ |
||
74 | View Code Duplication | protected function trans($id, array $parameters = array(), $domain = null, $locale = null) { |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
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. ![]() |
|||
75 | /** |
||
76 | * |
||
77 | * @var TranslatorInterface $translator |
||
78 | */ |
||
79 | $translator = $this->getTranslator(); |
||
80 | return $translator->trans($id, $parameters, $domain, $locale); |
||
81 | } |
||
82 | |||
83 | /** |
||
84 | * Returns the translator service |
||
85 | * |
||
86 | * @return TranslatorInterface |
||
87 | */ |
||
88 | protected function getTranslator() { |
||
89 | return $this->get('translator'); |
||
90 | } |
||
91 | |||
92 | /** |
||
93 | * Returns the paginator service |
||
94 | * |
||
95 | * @return \Knp\Component\Pager\PaginatorInterface |
||
96 | */ |
||
97 | protected function getPaginator() { |
||
98 | return $this->get('knp_paginator'); |
||
99 | } |
||
100 | |||
101 | /** |
||
102 | * Returns the stopwatch service if available |
||
103 | * |
||
104 | * @return Stopwatch|NULL |
||
0 ignored issues
–
show
|
|||
105 | */ |
||
106 | protected function getStopWatch() { |
||
107 | if($this->has('debug.stopwatch')) { |
||
108 | return $this->get('debug.stopwatch'); |
||
109 | } |
||
110 | return null; |
||
111 | } |
||
112 | |||
113 | /** |
||
114 | * Checks whether the current user has the specified role or not |
||
115 | * |
||
116 | * @param string $role |
||
117 | * @throws \LogicException |
||
118 | * @return boolean |
||
119 | */ |
||
120 | protected function hasRole($role) { |
||
121 | if(!$this->container->has('security.authorization_checker')) { |
||
122 | throw new \LogicException('The SecurityBundle is not registered in your application.'); |
||
123 | } |
||
124 | return false !== $this->get('security.authorization_checker')->isGranted($role); |
||
125 | } |
||
126 | |||
127 | /** |
||
128 | * Returns the repository for the given clazz |
||
129 | * |
||
130 | * @param string $class |
||
131 | * @return ObjectRepository |
||
132 | */ |
||
133 | protected function getRepository($class) { |
||
134 | return $this->getDoctrine()->getManagerForClass($class)->getRepository($class); |
||
135 | } |
||
136 | } |
This check looks for
@param
annotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.