Completed
Pull Request — develop (#522)
by ANTHONIUS
12:09
created

Module::getRequiredDirectoryLists()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 4
c 0
b 0
f 0
ccs 0
cts 2
cp 0
rs 10
cc 1
nc 1
nop 1
crap 2
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/Image'
33
        ];
34
    }
35
36
    /**
37
     * Loads module specific configuration.
38
     *
39
     * @return array
40
     */
41 5
    public function getConfig()
42
    {
43 5
        return ModuleConfigLoader::load(__DIR__ . '/../config');
44
    }
45
46
47 4
    public function onBootstrap(EventInterface $e)
48
    {
49
        /* @var $e MvcEvent */
50 4
        $eventManager = $e->getApplication()->getEventManager();
51 4
        $sharedManager = $eventManager->getSharedManager();
52
53 4
        $createJobListener = new \Organizations\Acl\Listener\CheckJobCreatePermissionListener();
54 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

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