Completed
Push — develop ( 911e58...200791 )
by Carsten
13s
created

Module::onBootstrap()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 22
rs 9.568
c 0
b 0
f 0
cc 3
nc 2
nop 1
1
<?php
2
/**
3
 * YAWIK
4
 * Organizations Module Bootstrap
5
 *
6
 * @copyright (c) 2013 - 2016 Cross Solution (http://cross-solution.de)
7
 * @license   GPLv3
8
 */
9
10
namespace Organizations;
11
12
use Core\ModuleManager\ModuleConfigLoader;
13
use Zend\EventManager\EventInterface;
14
use Zend\ModuleManager\Feature\DependencyIndicatorInterface;
15
use Zend\Mvc\MvcEvent;
16
use Zend\ModuleManager\Feature\BootstrapListenerInterface;
17
18
/**
19
 * Bootstrap class of the organizations module
20
 */
21
class Module implements BootstrapListenerInterface, DependencyIndicatorInterface
22
{
23
    /**
24
     * Loads module specific configuration.
25
     *
26
     * @return array
27
     */
28
    public function getConfig()
29
    {
30
        return ModuleConfigLoader::load(__DIR__ . '/../config');
31
    }
32
33
34
    public function onBootstrap(EventInterface $e)
35
    {
36
        /* @var $e MvcEvent */
37
        $eventManager = $e->getApplication()->getEventManager();
38
        $sharedManager = $eventManager->getSharedManager();
39
40
        $createJobListener = new \Organizations\Acl\Listener\CheckJobCreatePermissionListener();
41
        $createJobListener->attachShared($sharedManager);
42
43
        if ($e->getRequest() instanceof \Zend\Http\Request) {
0 ignored issues
show
Bug introduced by
The class Zend\Http\Request does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
44
            $eventManager->attach(MvcEvent::EVENT_DISPATCH_ERROR, function (MvcEvent $event) {
45
                $serviceManager = $event->getApplication()
46
                    ->getServiceManager();
47
                $options = $serviceManager->get('Organizations/ImageFileCacheOptions');
48
                
49
                if ($options->getEnabled()) {
50
                    $serviceManager->get('Organizations\ImageFileCache\ApplicationListener')
51
                        ->onDispatchError($event);
52
                }
53
            });
54
        }
55
    }
56
57
    public function getModuleDependencies()
58
    {
59
        return [
60
            'Core',
61
            'Auth',
62
        ];
63
    }
64
}
65