Passed
Push — develop ( 28c299...928e2a )
by Mathias
12:40
created

Module::getConfig()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
c 0
b 0
f 0
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 0
crap 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 Core\Options\ModuleOptions as CoreOptions;
14
use Yawik\Composer\RequireDirectoryPermissionInterface;
15
use Zend\EventManager\EventInterface;
16
use Zend\ModuleManager\Feature\DependencyIndicatorInterface;
17
use Zend\Mvc\MvcEvent;
18
use Zend\ModuleManager\Feature\BootstrapListenerInterface;
19
20
/**
21
 * Bootstrap class of the organizations module
22
 */
23
class Module implements BootstrapListenerInterface, DependencyIndicatorInterface, RequireDirectoryPermissionInterface
24
{
25
    /**
26
     * @param CoreOptions $options
27
     * @return array
28
     */
29
    public function getRequiredDirectoryLists(CoreOptions $options)
30
    {
31
        return [
32
            $options->getPublicDir().'/static/Organizations',
33
            $options->getPublicDir().'/static/Organizations/Image',
34
        ];
35
    }
36
37
    /**
38
     * Loads module specific configuration.
39
     *
40
     * @return array
41
     */
42 5
    public function getConfig()
43
    {
44 5
        return ModuleConfigLoader::load(__DIR__ . '/../config');
45
    }
46
47
48 4
    public function onBootstrap(EventInterface $e)
49
    {
50
        /* @var $e MvcEvent */
51 4
        $eventManager = $e->getApplication()->getEventManager();
52 4
        $sharedManager = $eventManager->getSharedManager();
53
54 4
        $createJobListener = new \Organizations\Acl\Listener\CheckJobCreatePermissionListener();
55 4
        $createJobListener->attachShared($sharedManager);
0 ignored issues
show
Bug introduced by
It seems like $sharedManager can also be of type null; however, parameter $events of Organizations\Acl\Listen...istener::attachShared() does only seem to accept Zend\EventManager\SharedEventManagerInterface, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

55
        $createJobListener->attachShared(/** @scrutinizer ignore-type */ $sharedManager);
Loading history...
56
57 4
        if ($e->getRequest() instanceof \Zend\Http\Request) {
58 4
            $eventManager->attach(MvcEvent::EVENT_DISPATCH_ERROR, function (MvcEvent $event) {
59
                $serviceManager = $event->getApplication()
60
                    ->getServiceManager();
61
                $options = $serviceManager->get('Organizations/ImageFileCacheOptions');
62
                
63
                if ($options->getEnabled()) {
64
                    $serviceManager->get('Organizations\ImageFileCache\ApplicationListener')
65
                        ->onDispatchError($event);
66
                }
67 4
            });
68
        }
69 4
    }
70
71 5
    public function getModuleDependencies()
72
    {
73
        return [
74 5
            'Core',
75
            'Auth',
76
        ];
77
    }
78
}
79