Completed
Push — master ( 820852...60399b )
by Craig
05:47
created

HookController::checkAjaxToken()   A

Complexity

Conditions 4
Paths 5

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 4
eloc 8
c 1
b 0
f 0
nc 5
nop 1
dl 0
loc 13
rs 9.2
1
<?php
2
3
/*
4
 * This file is part of the Zikula package.
5
 *
6
 * Copyright Zikula Foundation - http://zikula.org/
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Zikula\Bundle\HookBundle\Controller;
13
14
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
15
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
16
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
17
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
18
use Symfony\Component\HttpFoundation\Request;
19
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
20
use Zikula\Bundle\HookBundle\Collector\HookCollectorInterface;
21
use Zikula\Common\Translator\TranslatorTrait;
22
use Zikula\Core\Response\Ajax\AjaxResponse;
23
use Zikula\ExtensionsModule\Entity\ExtensionEntity;
24
use Zikula\ThemeModule\Engine\Annotation\Theme;
25
26
/**
27
 * Class HookController
28
 * @Route("/hooks")
29
 */
30
class HookController extends Controller
31
{
32
    use TranslatorTrait;
33
34
    public function setTranslator($translator)
35
    {
36
        $this->translator = $translator;
37
    }
38
39
    /**
40
     * @Route("/{moduleName}", options={"zkNoBundlePrefix" = 1})
41
     * @Method("GET")
42
     * @Theme("admin")
43
     * @Template
44
     *
45
     * Display hooks user interface
46
     *
47
     * @param string $moduleName
48
     * @return array
49
     * @throws AccessDeniedException Thrown if the user doesn't have admin permissions over the module
50
     */
51
    public function editAction($moduleName)
52
    {
53
        $templateParameters = [];
54
        // get module's name and assign it to template
55
        $templateParameters['currentmodule'] = $moduleName;
56
57
        // check if user has admin permission on this module
58
        if (!$this->get('zikula_permissions_module.api.permission')->hasPermission($moduleName . '::', '::', ACCESS_ADMIN)) {
59
            throw new AccessDeniedException();
60
        }
61
62
        // find out the capabilities of the module
63
        $isProvider = $this->get('zikula_hook_bundle.collector.hook_collector')->isCapable($moduleName, HookCollectorInterface::HOOK_PROVIDER);
64
        $templateParameters['isProvider'] = $isProvider;
65
66
        $isSubscriber = $this->get('zikula_hook_bundle.collector.hook_collector')->isCapable($moduleName, HookCollectorInterface::HOOK_SUBSCRIBER);
67
        $templateParameters['isSubscriber'] = $isSubscriber;
68
69
        $isSubscriberSelfCapable = $this->get('zikula_hook_bundle.collector.hook_collector')->isCapable($moduleName, HookCollectorInterface::HOOK_SUBSCRIBE_OWN);
70
        $templateParameters['isSubscriberSelfCapable'] = $isSubscriberSelfCapable;
71
        $templateParameters['providerAreas'] = [];
72
73
        $nonPersistedProviders = $this->get('zikula_hook_bundle.collector.hook_collector')->getProviders();
74
        $nonPersistedSubscribers = $this->get('zikula_hook_bundle.collector.hook_collector')->getSubscribers();
75
76
        // get areas of module and bundle titles also
77
        if ($isProvider) {
78
            $providerAreas = $this->get('zikula_hook_bundle.collector.hook_collector')->getProviderAreasByOwner($moduleName);
79
            $templateParameters['providerAreas'] = $providerAreas;
80
81
            $providerAreasToTitles = [];
82
            foreach ($providerAreas as $providerArea) {
83
                if (isset($nonPersistedProviders[$providerArea])) {
84
                    $providerAreasToTitles[$providerArea] = $nonPersistedProviders[$providerArea]->getTitle();
85
                }
86
            }
87
            $templateParameters['providerAreasToTitles'] = $providerAreasToTitles;
88
        }
89
        $templateParameters['subscriberAreas'] = [];
90
        $templateParameters['hooksubscribers'] = [];
91
92
        if ($isSubscriber) {
93
            $subscriberAreas = $this->get('zikula_hook_bundle.collector.hook_collector')->getSubscriberAreasByOwner($moduleName);
94
            $templateParameters['subscriberAreas'] = $subscriberAreas;
95
96
            $subscriberAreasToTitles = [];
97
            $subscriberAreasToCategories = [];
98
            $subscriberAreasAndCategories = [];
99 View Code Duplication
            foreach ($subscriberAreas as $subscriberArea) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
100
                if (isset($nonPersistedSubscribers[$subscriberArea])) {
101
                    $subscriberAreasToTitles[$subscriberArea] = $nonPersistedSubscribers[$subscriberArea]->getTitle();
102
                    $category = $nonPersistedSubscribers[$subscriberArea]->getCategory();
103
                }
104
                $subscriberAreasToCategories[$subscriberArea] = $category;
0 ignored issues
show
Bug introduced by
The variable $category does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
105
                $subscriberAreasAndCategories[$category][] = $subscriberArea;
106
            }
107
            $templateParameters['subscriberAreasToTitles'] = $subscriberAreasToTitles;
108
            $templateParameters['subscriberAreasToCategories'] = $subscriberAreasToCategories;
109
            $templateParameters['subscriberAreasAndCategories'] = $subscriberAreasAndCategories;
110
        }
111
112
        // get available subscribers that can attach to provider
113
        if ($isProvider && !empty($providerAreas)) {
114
            /** @var ExtensionEntity[] $hooksubscribers */
115
            $hooksubscribers = $this->getExtensionsCapableOf(HookCollectorInterface::HOOK_SUBSCRIBER);
116
            $amountOfHookSubscribers = count($hooksubscribers);
117
            $amountOfAvailableSubscriberAreas = 0;
118
            for ($i = 0; $i < $amountOfHookSubscribers; $i++) {
119
                $hooksubscribers[$i] = $hooksubscribers[$i]->toArray();
120
                // don't allow subscriber and provider to be the same
121
                // unless subscriber has the ability to connect to it's own providers
122
                if ($hooksubscribers[$i]['name'] == $moduleName) {
123
                    unset($hooksubscribers[$i]);
124
                    continue;
125
                }
126
                // does the user have admin permissions on the subscriber module?
127 View Code Duplication
                if (!$this->get('zikula_permissions_module.api.permission')->hasPermission($hooksubscribers[$i]['name'] . "::", '::', ACCESS_ADMIN)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
128
                    unset($hooksubscribers[$i]);
129
                    continue;
130
                }
131
132
                // get the areas of the subscriber
133
                $hooksubscriberAreas = $this->get('zikula_hook_bundle.collector.hook_collector')->getSubscriberAreasByOwner($hooksubscribers[$i]['name']);
134
                $hooksubscribers[$i]['areas'] = $hooksubscriberAreas;
135
                $amountOfAvailableSubscriberAreas += count($hooksubscriberAreas);
136
137
                $hooksubscriberAreasToTitles = []; // and get the titles
138
                $hooksubscriberAreasToCategories = []; // and get the categories
139
                foreach ($hooksubscriberAreas as $hooksubscriberArea) {
140
                    if (isset($nonPersistedSubscribers[$hooksubscriberArea])) {
141
                        $hooksubscriberAreasToTitles[$hooksubscriberArea] = $nonPersistedSubscribers[$hooksubscriberArea]->getTitle();
142
                        $category = $nonPersistedSubscribers[$hooksubscriberArea]->getCategory();
143
                    }
144
                    $hooksubscriberAreasToCategories[$hooksubscriberArea] = $category;
145
                }
146
                $hooksubscribers[$i]['areasToTitles'] = $hooksubscriberAreasToTitles;
147
                $hooksubscribers[$i]['areasToCategories'] = $hooksubscriberAreasToCategories;
148
            }
149
            $templateParameters['hooksubscribers'] = $hooksubscribers;
150
            $templateParameters['total_available_subscriber_areas'] = $amountOfAvailableSubscriberAreas;
151
        } else {
152
            $templateParameters['total_available_subscriber_areas'] = 0;
153
        }
154
155
        // get providers that are already attached to the subscriber
156
        // and providers that can attach to the subscriber
157
        if ($isSubscriber && !empty($subscriberAreas)) {
158
            // get current sorting
159
            $currentSortingTitles = [];
160
            $currentSorting = [];
161
            $amountOfAttachedProviderAreas = 0;
162
            $amountOfSubscriberAreas = count($subscriberAreas);
163
            for ($i = 0; $i < $amountOfSubscriberAreas; $i++) {
164
                $sortsByArea = $this->get('hook_dispatcher')->getBindingsFor($subscriberAreas[$i]);
165
                foreach ($sortsByArea as $sba) {
166
                    $areaname = $sba['areaname'];
167
                    $category = $sba['category'];
168
169
                    if (!isset($currentSorting[$category])) {
170
                        $currentSorting[$category] = [];
171
                    }
172
173
                    if (!isset($currentSorting[$category][$subscriberAreas[$i]])) {
174
                        $currentSorting[$category][$subscriberAreas[$i]] = [];
175
                    }
176
177
                    array_push($currentSorting[$category][$subscriberAreas[$i]], $areaname);
178
                    $amountOfAttachedProviderAreas++;
179
180
                    // get the bundle title
181
                    if (isset($nonPersistedProviders[$areaname])) {
182
                        $currentSortingTitles[$areaname] = $nonPersistedProviders[$areaname]->getTitle();
183
                    }
184
                }
185
            }
186
            $templateParameters['areasSorting'] = $currentSorting;
187
            $templateParameters['areasSortingTitles'] = $currentSortingTitles;
188
            $templateParameters['total_attached_provider_areas'] = $amountOfAttachedProviderAreas;
189
190
            // get available providers
191
            /** @var ExtensionEntity[] $hookproviders */
192
            $hookproviders = $this->getExtensionsCapableOf(HookCollectorInterface::HOOK_PROVIDER);
193
            $amountOfHookProviders = count($hookproviders);
194
            $amountOfAvailableProviderAreas = 0;
195
            for ($i = 0; $i < $amountOfHookProviders; $i++) {
196
                $hookproviders[$i] = $hookproviders[$i]->toArray();
197
                // don't allow subscriber and provider to be the same
198
                // unless subscriber has the ability to connect to it's own providers
199
                if ($hookproviders[$i]['name'] == $moduleName && !$isSubscriberSelfCapable) {
200
                    unset($hookproviders[$i]);
201
                    continue;
202
                }
203
204
                // does the user have admin permissions on the provider module?
205 View Code Duplication
                if (!$this->get('zikula_permissions_module.api.permission')->hasPermission($hookproviders[$i]['name']."::", '::', ACCESS_ADMIN)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
206
                    unset($hookproviders[$i]);
207
                    continue;
208
                }
209
210
                // get the areas of the provider
211
                $hookproviderAreas = $this->get('zikula_hook_bundle.collector.hook_collector')->getProviderAreasByOwner($hookproviders[$i]['name']);
212
                $hookproviders[$i]['areas'] = $hookproviderAreas;
213
                $amountOfAvailableProviderAreas += count($hookproviderAreas);
214
215
                $hookproviderAreasToTitles = []; // and get the titles
216
                $hookproviderAreasToCategories = []; // and get the categories
217
                $hookproviderAreasAndCategories = []; // and build array with category => areas
218 View Code Duplication
                foreach ($hookproviderAreas as $hookproviderArea) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
219
                    if (isset($nonPersistedProviders[$hookproviderArea])) {
220
                        $hookproviderAreasToTitles[$hookproviderArea] = $nonPersistedProviders[$hookproviderArea]->getTitle();
221
                        $category = $nonPersistedProviders[$hookproviderArea]->getCategory();
222
                    }
223
                    $hookproviderAreasToCategories[$hookproviderArea] = $category;
224
                    $hookproviderAreasAndCategories[$category][] = $hookproviderArea;
225
                }
226
                $hookproviders[$i]['areasToTitles'] = $hookproviderAreasToTitles;
227
                $hookproviders[$i]['areasToCategories'] = $hookproviderAreasToCategories;
228
                $hookproviders[$i]['areasAndCategories'] = $hookproviderAreasAndCategories;
229
            }
230
            $templateParameters['hookproviders'] = $hookproviders;
231
            $templateParameters['total_available_provider_areas'] = $amountOfAvailableProviderAreas;
232
        } else {
233
            $templateParameters['hookproviders'] = [];
234
        }
235
        $templateParameters['hookDispatcher'] = $this->get('hook_dispatcher');
236
        $request = $this->get('request_stack')->getCurrentRequest();
237
        $request->attributes->set('_zkModule', $moduleName);
238
        $request->attributes->set('_zkType', 'admin');
239
        $request->attributes->set('_zkFunc', 'Hooks');
240
241
        return $templateParameters;
242
    }
243
244
    /**
245
     * @Route("/togglestatus", options={"expose"=true})
246
     * @Method("POST")
247
     *
248
     * Attach/detach a subscriber area to a provider area
249
     *
250
     * @param Request $request
251
     *
252
     *  subscriberarea string area to be attached/detached
253
     *  providerarea   string area to attach/detach
254
     *
255
     * @return AjaxResponse
256
     *
257
     * @throws \InvalidArgumentException Thrown if either the subscriber, provider or subscriberArea parameters are empty
258
     * @throws \RuntimeException Thrown if either the subscriber or provider module isn't available
259
     * @throws AccessDeniedException Thrown if the user doesn't have admin access to either the subscriber or provider modules
260
     */
261
    public function toggleSubscribeAreaStatusAction(Request $request)
262
    {
263
        $this->setTranslator($this->get('translator.default'));
264
        $this->checkAjaxToken();
265
266
        // get subscriberarea from POST
267
        $subscriberArea = $request->request->get('subscriberarea', '');
268
        if (empty($subscriberArea)) {
269
            throw new \InvalidArgumentException($this->__('No subscriber area passed.'));
270
        }
271
272
        // get subscriber module based on area and do some checks
273
        $subscriber = $this->get('zikula_hook_bundle.collector.hook_collector')->getSubscriber($subscriberArea);
274
        if (empty($subscriber)) {
275
            throw new \InvalidArgumentException($this->__f('Module "%s" is not a valid subscriber.', ['%s' => $subscriber->getOwner()]));
276
        }
277 View Code Duplication
        if (!$this->get('kernel')->isBundle($subscriber->getOwner())) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
278
            throw new \RuntimeException($this->__f('Subscriber module "%s" is not available.', ['%s' => $subscriber->getOwner()]));
279
        }
280 View Code Duplication
        if (!$this->get('zikula_permissions_module.api.permission')->hasPermission($subscriber->getOwner() . '::', '::', ACCESS_ADMIN)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
281
            throw new AccessDeniedException();
282
        }
283
284
        // get providerarea from POST
285
        $providerArea = $request->request->get('providerarea', '');
286
        if (empty($providerArea)) {
287
            throw new \InvalidArgumentException($this->__('No provider area passed.'));
288
        }
289
290
        // get provider module based on area and do some checks
291
        $provider = $this->get('zikula_hook_bundle.collector.hook_collector')->getProvider($providerArea);
292
        if (empty($provider)) {
293
            throw new \InvalidArgumentException($this->__f('Module "%s" is not a valid provider.', ['%s' => $provider->getOwner()]));
294
        }
295
        if (!$this->get('kernel')->isBundle($provider->getOwner())) {
296
            throw new \RuntimeException($this->__f('Provider module "%s" is not available.', ['%s' => $provider->getOwner()]));
297
        }
298 View Code Duplication
        if (!$this->get('zikula_permissions_module.api.permission')->hasPermission($provider->getOwner() . '::', '::', ACCESS_ADMIN)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
299
            throw new AccessDeniedException();
300
        }
301
302
        // check if binding between areas exists
303
        $binding = $this->get('hook_dispatcher')->getBindingBetweenAreas($subscriberArea, $providerArea);
304
        if (!$binding) {
305
            $this->get('hook_dispatcher')->bindSubscriber($subscriberArea, $providerArea);
306
        } else {
307
            $this->get('hook_dispatcher')->unbindSubscriber($subscriberArea, $providerArea);
308
        }
309
310
        // ajax response
311
        $response = [
312
            'result' => true,
313
            'action' => $binding ? 'unbind' : 'bind',
314
            'subscriberarea' => $subscriberArea,
315
            'subscriberarea_id' => md5($subscriberArea),
316
            'providerarea' => $providerArea,
317
            'providerarea_id' => md5($providerArea),
318
            'isSubscriberSelfCapable' => $this->get('zikula_hook_bundle.collector.hook_collector')->isCapable($subscriber->getOwner(), HookCollectorInterface::HOOK_SUBSCRIBE_OWN)
319
        ];
320
321
        return new AjaxResponse($response);
322
    }
323
324
    /**
325
     * @Route("/changeorder", options={"expose"=true})
326
     * @Method("POST")
327
     *
328
     * changeproviderareaorder
329
     * This function changes the order of the providers' areas that are attached to a subscriber
330
     *
331
     * @param Request $request
332
     *
333
     *  subscriber    string     name of the subscriber
334
     *  providerorder array      array of sorted provider ids
335
     *
336
     * @return AjaxResponse
337
     *
338
     * @throws \InvalidArgumentException Thrown if the subscriber or subscriberarea parameters aren't valid
339
     * @throws \RuntimeException Thrown if the subscriber module isn't available
340
     * @throws AccessDeniedException Thrown if the user doesn't have admin access to the subscriber module
341
     */
342
    public function changeProviderAreaOrderAction(Request $request)
343
    {
344
        $this->setTranslator($this->get('translator.default'));
345
        $this->checkAjaxToken();
346
347
        // get subscriberarea from POST
348
        $subscriberarea = $request->request->get('subscriberarea', '');
349
        if (empty($subscriberarea)) {
350
            throw new \InvalidArgumentException($this->__('No subscriber area passed.'));
351
        }
352
353
        // get subscriber module based on area and do some checks
354
        $subscriber = $this->get('zikula_hook_bundle.collector.hook_collector')->getSubscriber($subscriberarea);
355
        if (empty($subscriber)) {
356
            throw new \InvalidArgumentException($this->__f('Module "%s" is not a valid subscriber.', ['%s' => $subscriber->getOwner()]));
357
        }
358 View Code Duplication
        if (!$this->get('kernel')->isBundle($subscriber->getOwner())) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
359
            throw new \RuntimeException($this->__f('Subscriber module "%s" is not available.', ['%s' => $subscriber->getOwner()]));
360
        }
361 View Code Duplication
        if (!$this->get('zikula_permissions_module.api.permission')->hasPermission($subscriber->getOwner() . '::', '::', ACCESS_ADMIN)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
362
            throw new AccessDeniedException();
363
        }
364
365
        // get providers' areas from POST
366
        $providerarea = $request->request->get('providerarea', '');
367
        if (!(is_array($providerarea) && count($providerarea) > 0)) {
368
            throw new \InvalidArgumentException($this->__('Providers\' areas order is not an array.'));
369
        }
370
371
        // set sorting
372
        $this->get('hook_dispatcher')->setBindOrder($subscriberarea, $providerarea);
373
374
        $ol_id = $request->request->get('ol_id', '');
375
376
        return new AjaxResponse(['result' => true, 'ol_id' => $ol_id]);
377
    }
378
379
    /**
380
     * Check the CSRF token.
381
     * Checks will fall back to $token check if automatic checking fails
382
     *
383
     * @param string $token Token, default null
384
     * @throws AccessDeniedException If the CSFR token fails
385
     * @throws \Exception if request is not an XmlHttpRequest
386
     * @return void
387
     */
388
    private function checkAjaxToken($token = null)
389
    {
390
        $currentRequest = $this->get('request_stack')->getCurrentRequest();
391
        if (!$currentRequest->isXmlHttpRequest()) {
392
            throw new \Exception();
393
        }
394
        // @todo how to SET the $_SERVER['HTTP_X_ZIKULA_AJAX_TOKEN'] ?
395
        $headerToken = ($currentRequest->server->has('HTTP_X_ZIKULA_AJAX_TOKEN')) ? $currentRequest->server->get('HTTP_X_ZIKULA_AJAX_TOKEN') : null;
396
        if ($headerToken == $currentRequest->getSession()->getId()) {
397
            return;
398
        }
399
        $this->get('zikula_core.common.csrf_token_handler')->validate($token);
400
    }
401
402
    private function getExtensionsCapableOf($type)
403
    {
404
        $owners = $this->get('zikula_hook_bundle.collector.hook_collector')->getOwnersCapableOf($type);
405
        $extensions = [];
406
        foreach ($owners as $owner) {
407
            $extensions[] = $this->get('zikula_extensions_module.extension_repository')->findOneBy(['name' => $owner]);
408
        }
409
410
        return $extensions;
411
    }
412
}
413