Module   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Test Coverage

Coverage 55%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 6
eloc 26
dl 0
loc 60
ccs 11
cts 20
cp 0.55
rs 10
c 2
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getRequiredDirectoryLists() 0 5 1
A onBootstrap() 0 18 3
A getConfig() 0 3 1
A getModuleDependencies() 0 5 1
1
<?php
2
/**
3
 * YAWIK
4
 * Organizations Module Bootstrap
5
 *
6
 * @copyright https://yawik.org/COPYRIGHT.php
7
 * @license   GPLv3
8
 */
9
10
namespace Organizations;
11
12
use Core\ModuleManager\Feature\VersionProviderInterface;
13
use Core\ModuleManager\Feature\VersionProviderTrait;
14
use Core\ModuleManager\ModuleConfigLoader;
15
use Core\Options\ModuleOptions as CoreOptions;
16
use Yawik\Composer\RequireDirectoryPermissionInterface;
17
use Laminas\EventManager\EventInterface;
18
use Laminas\ModuleManager\Feature\DependencyIndicatorInterface;
19
use Laminas\Mvc\MvcEvent;
20
use Laminas\ModuleManager\Feature\BootstrapListenerInterface;
21
22
/**
23
 * Bootstrap class of the organizations module
24
 */
25
class Module implements
26
    BootstrapListenerInterface,
27
    DependencyIndicatorInterface,
28
    RequireDirectoryPermissionInterface,
29
    VersionProviderInterface
30
{
31
    use VersionProviderTrait;
32
33
    const VERSION = \Core\Module::VERSION;
34
    /**
35
     * @param CoreOptions $options
36
     * @return array
37
     */
38
    public function getRequiredDirectoryLists(CoreOptions $options)
39
    {
40
        return [
41
            $options->getPublicDir().'/static/Organizations',
42
            $options->getPublicDir().'/static/Organizations/Image',
43
        ];
44
    }
45
46
    /**
47
     * Loads module specific configuration.
48
     *
49
     * @return array
50
     */
51 5
    public function getConfig()
52
    {
53 5
        return ModuleConfigLoader::load(__DIR__ . '/../config');
54
    }
55
56
57 4
    public function onBootstrap(EventInterface $e)
58
    {
59
        /* @var $e MvcEvent */
60 4
        $eventManager = $e->getApplication()->getEventManager();
61 4
        $sharedManager = $eventManager->getSharedManager();
62
63 4
        $createJobListener = new \Organizations\Acl\Listener\CheckJobCreatePermissionListener();
64 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 Laminas\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

64
        $createJobListener->attachShared(/** @scrutinizer ignore-type */ $sharedManager);
Loading history...
65
66 4
        if ($e->getRequest() instanceof \Laminas\Http\Request) {
67
            $eventManager->attach(MvcEvent::EVENT_DISPATCH_ERROR, function (MvcEvent $event) {
68
                $serviceManager = $event->getApplication()
69
                    ->getServiceManager();
70
                $options = $serviceManager->get('Organizations/ImageFileCacheOptions');
71
72
                if ($options->getEnabled()) {
73
                    $serviceManager->get('Organizations\ImageFileCache\ApplicationListener')
74
                        ->onDispatchError($event);
75
                }
76 4
            });
77
        }
78
    }
79
80 5
    public function getModuleDependencies()
81
    {
82
        return [
83 5
            'Core',
84
            'Auth',
85
        ];
86
    }
87
}
88