ContainerConfig   A
last analyzed

Complexity

Total Complexity 12

Size/Duplication

Total Lines 118
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 23
dl 0
loc 118
rs 10
c 1
b 0
f 0
wmc 12

12 Methods

Rating   Name   Duplication   Size   Complexity  
A setupEntityManager() 0 3 1
A setupServerRequest() 0 3 1
A setupMailer() 0 3 1
A setupLogger() 0 3 1
A setupSession() 0 3 1
A setupDBConnection() 0 3 1
A setupRouter() 0 3 1
A define() 0 14 1
A setupAcl() 0 3 1
A modify() 0 2 1
A setupDispatcher() 0 3 1
A setupTranslator() 0 3 1
1
<?php
2
/**
3
 * @package EBloodBank
4
 * @since   1.6
5
 */
6
namespace EBloodBank;
7
8
use Gettext;
9
use Aura\Di\Container;
10
use Aura\Dispatcher\Dispatcher;
11
12
/**
13
 * @since 1.6
14
 */
15
class ContainerConfig extends \Aura\Di\ContainerConfig
16
{
17
    /**
18
     * @return void
19
     * @since 1.6
20
     */
21
    public function define(Container $container) : void
22
    {
23
        $this->setupLogger($container);
24
        $this->setupServerRequest($container);
25
        $this->setupTranslator($container);
26
        $this->setupDBConnection($container);
27
        $this->setupEntityManager($container);
28
        $this->setupRouter($container);
29
        $this->setupMailer($container);
30
        $this->setupSession($container);
31
        $this->setupAcl($container);
32
        $this->setupDispatcher($container);
33
        $container->set('viewFactory', $container->lazyNew(Views\ViewFactory::class, [$container]));
34
        $container->set('eventManager', $container->lazy(new EventManagerFactory(), $container));
35
    }
36
37
    /**
38
     * @return void
39
     * @since 1.6
40
     */
41
    public function modify(Container $container) : void
42
    {
43
    }
44
45
    /**
46
     * @return void
47
     * @since 1.6
48
     */
49
    protected function setupLogger(Container $container)
50
    {
51
        $container->set('logger', $container->lazy(new LoggerFactory(), $container));
52
    }
53
54
    /**
55
     * @return void
56
     * @since 1.6
57
     */
58
    protected function setupServerRequest(Container $container)
59
    {
60
        $container->set('request', $container->lazy(new ServerRequestFactory(), $container));
61
    }
62
63
    /**
64
     * @return void
65
     * @since 1.0
66
     */
67
    protected function setupTranslator(Container $container)
68
    {
69
        $container->set('translator', $container->lazyNew(Gettext\Translator::class));
70
    }
71
72
    /**
73
     * @return void
74
     * @since 1.6
75
     */
76
    protected function setupDBConnection(Container $container)
77
    {
78
        $container->set('db_connection', $container->lazy(new DbConnectionFactory(), $container));
79
    }
80
81
    /**
82
     * @return void
83
     * @since 1.6
84
     */
85
    protected function setupEntityManager(Container $container)
86
    {
87
        $container->set('entity_manager', $container->lazy(new EntityManagerFactory(), $container));
88
    }
89
90
    /**
91
     * @return void
92
     * @since 1.6
93
     */
94
    protected function setupRouter(Container $container)
95
    {
96
        $container->set('router', $container->lazy(new RouterFactory(), $container));
97
    }
98
99
    /**
100
     * @return void
101
     * @since 1.6
102
     */
103
    protected function setupMailer(Container $container)
104
    {
105
        $container->set('mailer', $container->lazy(new SwiftMailerFactory(), $container));
106
    }
107
108
    /**
109
     * @return void
110
     * @since 1.6
111
     */
112
    protected function setupSession(Container $container)
113
    {
114
        $container->set('session', $container->lazy(new SessionFactory(), $container));
115
    }
116
117
    /**
118
     * @return void
119
     * @since 1.6
120
     */
121
    protected function setupAcl(Container $container)
122
    {
123
        $container->set('acl', $container->lazy(new AclFactory(), $container));
124
    }
125
126
    /**
127
     * @return void
128
     * @since 1.6
129
     */
130
    protected function setupDispatcher(Container $container)
131
    {
132
        $container->set('dispatcher', $container->lazyNew(Dispatcher::class));
133
    }
134
}
135