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 | /* This file is part of the Thelia package. */ |
||
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 | |||
14 | namespace Dealer\Controller; |
||
15 | |||
16 | use Dealer\Controller\Base\BaseController; |
||
17 | use Dealer\Dealer; |
||
18 | use Dealer\Model\DealerBrand; |
||
19 | use Propel\Runtime\Propel; |
||
20 | use Symfony\Component\HttpFoundation\RedirectResponse; |
||
21 | use Thelia\Core\Security\AccessManager; |
||
22 | use Thelia\Core\Security\Resource\AdminResources; |
||
23 | use Thelia\Tools\URL; |
||
24 | |||
25 | /** |
||
26 | * Class BrandLinkController |
||
27 | * @package Dealer\Controller |
||
28 | */ |
||
29 | class BrandLinkController extends BaseController |
||
30 | { |
||
31 | const CONTROLLER_ENTITY_NAME = "dealer_brand_link"; |
||
32 | const CONTROLLER_CHECK_RESOURCE = Dealer::RESOURCES_ASSOCIATED; |
||
33 | /** |
||
34 | * @inheritDoc |
||
35 | */ |
||
36 | protected function getListRenderTemplate() |
||
37 | { |
||
38 | $id = $this->getRequest()->query->get("dealer_id"); |
||
39 | |||
40 | return new RedirectResponse(URL::getInstance()->absoluteUrl("/admin/module/Dealer/dealer/edit#associated", |
||
41 | ["dealer_id" => $id, ])); |
||
42 | } |
||
43 | |||
44 | /** |
||
45 | * @inheritDoc |
||
46 | */ |
||
47 | protected function redirectToListTemplate() |
||
48 | { |
||
49 | $id = $this->getRequest()->request->get("dealer_id"); |
||
50 | |||
51 | return new RedirectResponse(URL::getInstance()->absoluteUrl("/admin/module/Dealer/dealer/edit#associated", |
||
52 | ["dealer_id" => $id, ])); |
||
53 | } |
||
54 | |||
55 | /** |
||
56 | * @inheritDoc |
||
57 | */ |
||
58 | protected function getEditRenderTemplate() |
||
59 | { |
||
60 | // TODO: Implement getEditRenderTemplate() method. |
||
61 | } |
||
62 | |||
63 | /** |
||
64 | * @inheritDoc |
||
65 | */ |
||
66 | protected function getCreateRenderTemplate() |
||
67 | { |
||
68 | // TODO: Implement getCreateRenderTemplate() method. |
||
69 | } |
||
70 | |||
71 | /** |
||
72 | * @inheritDoc |
||
73 | */ |
||
74 | protected function getObjectId($object) |
||
75 | { |
||
76 | /** @var DealerBrand $object */ |
||
77 | return $object->getId(); |
||
78 | } |
||
79 | |||
80 | /** |
||
81 | * @inheritDoc |
||
82 | */ |
||
83 | protected function getExistingObject() |
||
84 | { |
||
85 | // TODO: Implement getExistingObject() method. |
||
86 | } |
||
87 | |||
88 | /** |
||
89 | * @inheritDoc |
||
90 | */ |
||
91 | protected function hydrateObjectForm($object) |
||
92 | { |
||
93 | // TODO: Implement hydrateObjectForm() method. |
||
94 | } |
||
95 | |||
96 | /** |
||
97 | * Method to get current controller associated service |
||
98 | * @return object |
||
99 | */ |
||
100 | protected function getService() |
||
101 | { |
||
102 | if (!$this->service) { |
||
103 | $this->service = $this->getContainer()->get("dealer_brand_link_service"); |
||
104 | } |
||
105 | |||
106 | return $this->service; |
||
107 | } |
||
108 | |||
109 | /** |
||
110 | * Method to get Base Creation Form |
||
111 | * @return \Thelia\Form\BaseForm |
||
112 | */ |
||
113 | protected function getCreationForm() |
||
114 | { |
||
115 | return $this->createForm(static::CONTROLLER_ENTITY_NAME . "_create"); |
||
116 | } |
||
117 | |||
118 | /** |
||
119 | * Delete an object |
||
120 | * |
||
121 | * @return \Thelia\Core\HttpFoundation\Response the response |
||
122 | */ |
||
123 | public function deleteAction() |
||
124 | { |
||
125 | // Check current user authorization |
||
126 | if (null !== $response = $this->checkAuth(AdminResources::MODULE, Dealer::getModuleCode(), |
||
127 | AccessManager::DELETE) |
||
128 | ) { |
||
129 | return $response; |
||
130 | } |
||
131 | |||
132 | $con = Propel::getConnection(); |
||
133 | $con->beginTransaction(); |
||
134 | try { |
||
135 | // Check token |
||
136 | $this->getTokenProvider()->checkToken( |
||
137 | $this->getRequest()->query->get("_token") |
||
138 | ); |
||
139 | $data = [ |
||
140 | "brand_id" => $this->getRequest()->request->get(static::CONTROLLER_ENTITY_NAME . "_id"), |
||
141 | "dealer_id" => $this->getRequest()->request->get("dealer_id"), |
||
142 | ]; |
||
143 | $this->getService()->deleteFromArray($data); |
||
144 | $con->commit(); |
||
145 | |||
146 | if ($this->getRequest()->request->get("success_url") == null) { |
||
147 | return $this->redirectToListTemplate(); |
||
0 ignored issues
–
show
|
|||
148 | } else { |
||
149 | return new RedirectResponse(URL::getInstance()->absoluteUrl($this->getRequest()->request->get("success_url"))); |
||
0 ignored issues
–
show
The return type of
return new \Symfony\Comp...->get('success_url'))); (Symfony\Component\HttpFoundation\RedirectResponse ) is incompatible with the return type documented by Dealer\Controller\BrandL...ontroller::deleteAction of type Thelia\Core\HttpFoundation\Response .
If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design. Let’s take a look at an example: class Author {
private $name;
public function __construct($name) {
$this->name = $name;
}
public function getName() {
return $this->name;
}
}
abstract class Post {
public function getAuthor() {
return 'Johannes';
}
}
class BlogPost extends Post {
public function getAuthor() {
return new Author('Johannes');
}
}
class ForumPost extends Post { /* ... */ }
function my_function(Post $post) {
echo strtoupper($post->getAuthor());
}
Our function ![]() |
|||
150 | } |
||
151 | } catch (\Exception $e) { |
||
152 | $con->rollBack(); |
||
153 | |||
154 | return $this->renderAfterDeleteError($e); |
||
155 | } |
||
156 | } |
||
157 | } |
||
158 |
If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.
Let’s take a look at an example:
Our function
my_function
expects aPost
object, and outputs the author of the post. The base classPost
returns a simple string and outputting a simple string will work just fine. However, the child classBlogPost
which is a sub-type ofPost
instead decided to return anobject
, and is therefore violating the SOLID principles. If aBlogPost
were passed tomy_function
, PHP would not complain, but ultimately fail when executing thestrtoupper
call in its body.