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 Sulu. |
||
5 | * |
||
6 | * (c) MASSIVE ART WebServices GmbH |
||
7 | * |
||
8 | * This source file is subject to the MIT license that is bundled |
||
9 | * with this source code in the file LICENSE. |
||
10 | */ |
||
11 | |||
12 | namespace Sulu\Component\DocumentManager; |
||
13 | |||
14 | use Symfony\Component\EventDispatcher\EventDispatcherInterface; |
||
15 | use Symfony\Component\OptionsResolver\OptionsResolver; |
||
16 | |||
17 | class DocumentManager implements DocumentManagerInterface |
||
18 | { |
||
19 | /** |
||
20 | * @var EventDispatcherInterface |
||
21 | */ |
||
22 | private $eventDispatcher; |
||
23 | |||
24 | /** |
||
25 | * @var array Cached options resolver instances |
||
26 | */ |
||
27 | private $optionsResolvers = []; |
||
28 | |||
29 | /** |
||
30 | * @param EventDispatcherInterface $eventDispatcher |
||
31 | */ |
||
32 | public function __construct(EventDispatcherInterface $eventDispatcher) |
||
33 | { |
||
34 | $this->eventDispatcher = $eventDispatcher; |
||
35 | } |
||
36 | |||
37 | /** |
||
38 | * {@inheritdoc} |
||
39 | */ |
||
40 | View Code Duplication | public function find($identifier, $locale = null, array $options = []) |
|
0 ignored issues
–
show
|
|||
41 | { |
||
42 | $options = $this->getOptionsResolver(Events::FIND)->resolve($options); |
||
43 | |||
44 | $event = new Event\FindEvent($identifier, $locale, $options); |
||
45 | $this->eventDispatcher->dispatch(Events::FIND, $event); |
||
46 | |||
47 | return $event->getDocument(); |
||
48 | } |
||
49 | |||
50 | /** |
||
51 | * {@inheritdoc} |
||
52 | */ |
||
53 | public function create($alias) |
||
54 | { |
||
55 | $event = new Event\CreateEvent($alias); |
||
56 | $this->eventDispatcher->dispatch(Events::CREATE, $event); |
||
57 | |||
58 | return $event->getDocument(); |
||
59 | } |
||
60 | |||
61 | /** |
||
62 | * {@inheritdoc} |
||
63 | */ |
||
64 | View Code Duplication | public function persist($document, $locale = null, array $options = []) |
|
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.
Loading history...
|
|||
65 | { |
||
66 | $options = $this->getOptionsResolver(Events::FIND)->resolve($options); |
||
67 | |||
68 | $event = new Event\PersistEvent($document, $locale, $options); |
||
69 | $this->eventDispatcher->dispatch(Events::PERSIST, $event); |
||
70 | } |
||
71 | |||
72 | /** |
||
73 | * {@inheritdoc} |
||
74 | */ |
||
75 | public function remove($document) |
||
76 | { |
||
77 | $event = new Event\RemoveEvent($document); |
||
78 | $this->eventDispatcher->dispatch(Events::REMOVE, $event); |
||
79 | } |
||
80 | |||
81 | /** |
||
82 | * {@inheritdoc} |
||
83 | */ |
||
84 | public function move($document, $destId) |
||
85 | { |
||
86 | $event = new Event\MoveEvent($document, $destId); |
||
87 | $this->eventDispatcher->dispatch(Events::MOVE, $event); |
||
88 | } |
||
89 | |||
90 | /** |
||
91 | * {@inheritdoc} |
||
92 | */ |
||
93 | public function copy($document, $destPath) |
||
94 | { |
||
95 | $event = new Event\CopyEvent($document, $destPath); |
||
96 | $this->eventDispatcher->dispatch(Events::COPY, $event); |
||
97 | |||
98 | return $event->getCopiedPath(); |
||
99 | } |
||
100 | |||
101 | /** |
||
102 | * {@inheritdoc} |
||
103 | */ |
||
104 | public function reorder($document, $destId, $after = false) |
||
105 | { |
||
106 | $event = new Event\ReorderEvent($document, $destId, $after); |
||
107 | $this->eventDispatcher->dispatch(Events::REORDER, $event); |
||
108 | } |
||
109 | |||
110 | /** |
||
111 | * {@inheritdoc} |
||
112 | */ |
||
113 | public function refresh($document) |
||
114 | { |
||
115 | $event = new Event\RefreshEvent($document); |
||
116 | $this->eventDispatcher->dispatch(Events::REFRESH, $event); |
||
117 | } |
||
118 | |||
119 | /** |
||
120 | * {@inheritdoc} |
||
121 | */ |
||
122 | public function flush() |
||
123 | { |
||
124 | $event = new Event\FlushEvent(); |
||
125 | $this->eventDispatcher->dispatch(Events::FLUSH, $event); |
||
126 | } |
||
127 | |||
128 | /** |
||
129 | * {@inheritdoc} |
||
130 | */ |
||
131 | public function clear() |
||
132 | { |
||
133 | $event = new Event\ClearEvent(); |
||
134 | $this->eventDispatcher->dispatch(Events::CLEAR, $event); |
||
135 | } |
||
136 | |||
137 | /** |
||
138 | * {@inheritdoc} |
||
139 | */ |
||
140 | public function createQuery($query, $locale = null, array $options = []) |
||
141 | { |
||
142 | $event = new Event\QueryCreateEvent($query, $locale, $options); |
||
143 | $this->eventDispatcher->dispatch(Events::QUERY_CREATE, $event); |
||
144 | |||
145 | return $event->getQuery(); |
||
146 | } |
||
147 | |||
148 | /** |
||
149 | * {@inheritdoc} |
||
150 | */ |
||
151 | public function createQueryBuilder() |
||
152 | { |
||
153 | $event = new Event\QueryCreateBuilderEvent(); |
||
154 | $this->eventDispatcher->dispatch(Events::QUERY_CREATE_BUILDER, $event); |
||
155 | |||
156 | return $event->getQueryBuilder(); |
||
157 | } |
||
158 | |||
159 | /** |
||
160 | * {@inheritdoc} |
||
161 | */ |
||
162 | private function getOptionsResolver($eventName) |
||
163 | { |
||
164 | if (isset($this->optionsResolvers[$eventName])) { |
||
165 | return $this->optionsResolvers[$eventName]; |
||
166 | } |
||
167 | |||
168 | $resolver = new OptionsResolver(); |
||
169 | $resolver->setDefault('locale', null); |
||
170 | |||
171 | $event = new Event\ConfigureOptionsEvent($resolver); |
||
172 | $this->eventDispatcher->dispatch(Events::CONFIGURE_OPTIONS, $event); |
||
173 | |||
174 | $this->optionsResolvers[$eventName] = $resolver; |
||
175 | |||
176 | return $resolver; |
||
177 | } |
||
178 | } |
||
179 |
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.