Proyectos de Subversion LeadersLinked - Services

Rev

Rev 232 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
<?php
2
 
3
/**
4
 * Global Configuration Override
5
 *
6
 * You can use this file for overriding configuration values from modules, etc.
7
 * You would place values in here that are agnostic to the environment and not
8
 * sensitive to security.
9
 *
10
 * NOTE: In practice, this file will typically be INCLUDED in your source
11
 * control, so do not include passwords or other sensitive information in this
12
 * file.
13
 */
14
use Laminas\Session\Storage\SessionArrayStorage;
15
use Laminas\Session\Validator\RemoteAddr;
16
use Laminas\Session\Validator\HttpUserAgent;
17
use LeadersLinked\Handler\SessionHandler;
18
use Laminas\Session\Storage\SessionStorage;
19
use LeadersLinked\Cache\CacheImpl;
20
use LeadersLinked\Handler\SessionCacheHandler;
21
 
22
 
23
 
24
return [
301 www 25
    /*
1 efrain 26
    'session' => [
27
        'config' => [
28
            'class' => 'Laminas\Session\Config\SessionConfig',
29
            'options' => [
30
                'name'              => 'LeadersLinked',
31
                'use_cookies'       => true,
32
                'cookie_lifetime'   => 60*60*24*30,
33
                'gc_maxlifetime'    => 60*60*24,
232 efrain 34
                'cookie_httponly'   => true,
35
                'cookie_secure'     => true
1 efrain 36
            ],
37
        ],
38
        'storage' => SessionArrayStorage::class,
39
        'validators' => [
40
            RemoteAddr::class,
41
            HttpUserAgent::class,
42
        ],
301 www 43
    ],*/
1 efrain 44
    'service_manager' => [
45
 
46
        'factories' => [
47
            //'Laminas\Db\Adapter\Adapter'  => 'Laminas\Db\Adapter\AdapterServiceFactory',
48
 
49
            'leaders-linked-cache' => function ($sm) {
50
                $config = $sm->get('config');
51
 
301 www 52
                $cache = CacheImpl::getInstance($config);
1 efrain 53
                return $cache;
54
 
55
            },
56
 
57
            'leaders-linked-db' => function ($sm) {
58
                $config = $sm->get('config');
59
 
60
                $sandbox = $config['leaderslinked.runmode.sandbox'];
61
                if($sandbox) {
62
                    $host       = $config['leaderslinked.database.sandbox_host'];
63
                    $port       = $config['leaderslinked.database.sandbox_port'];
64
                    $dbname     = $config['leaderslinked.database.sandbox_dbname'];
65
                    $user       = $config['leaderslinked.database.sandbox_user'];
66
                    $password   = $config['leaderslinked.database.sandbox_password'];
67
                } else {
68
                    $host       = $config['leaderslinked.database.production_host'];
69
                    $port       = $config['leaderslinked.database.production_port'];
70
                    $dbname     = $config['leaderslinked.database.production_dbname'];
71
                    $user       = $config['leaderslinked.database.production_user'];
72
                    $password   = $config['leaderslinked.database.production_password'];
73
                }
74
 
75
                $adapter = new \Laminas\Db\Adapter\Adapter([
76
                    'driver'            => 'Pdo',
77
                    'dsn'               => 'mysql:dbname=' . $dbname . ';host=' . $host . ';port=' . $port,
78
                    'username'                  => $user,
79
                    'password'                  => $password,
80
                    'driver_options'    => [
81
                        PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\''
82
                    ],
83
                ]);
84
 
85
            return $adapter;
86
 
87
            },
88
            'leaders-linked-log' => function($sm) {
89
                $formatter = new \Laminas\Log\Formatter\Base();
90
                $formatter->setDateTimeFormat('Y-m-d H:i:s');
91
 
92
                $mapping = array(
93
                    'timestamp'     => 'added_on',
94
                    'priority'      => 'priority_level',
95
                    'priorityName'  => 'priority_name',
96
                    'message'       => 'message',
97
                    'extra'       => [
98
                        'user_id'    => 'user_id',
99
                        'ip' => 'ip'
100
                    ]
101
                );
102
 
103
 
104
                $adapter = $sm->get('leaders-linked-db');
105
 
106
                $writer = new \Laminas\Log\Writer\Db($adapter, 'tbl_logs', $mapping);
107
                $writer->setFormatter($formatter);
108
 
109
                $logger = new \Laminas\Log\Logger();
110
                $logger->addWriter($writer);
111
 
112
 
113
 
114
                return $logger;
115
            },
301 www 116
          /*
1 efrain 117
            'leaders-linked-session' => function ($sm) {
118
                $config = $sm->get('config');
119
                if (isset($config['session'])) {
120
 
121
                    $session = $config['session'];
122
 
123
 
124
                    $sessionConfig = null;
125
                    if (isset($session['config'])) {
126
                        $class = isset($session['config']['class'])  ? $session['config']['class'] : 'Laminas\Session\Config\SessionConfig';
127
                        $options = isset($session['config']['options']) ? $session['config']['options'] : [];
128
 
129
 
130
                        $options['remember_me_seconds'] = 7200;  // 60 * 60 * 2seconds
131
                        $options['use_cookies'] = true;
132
                        $sessionConfig = new $class();
133
                        $sessionConfig->setOptions($options);
134
                    }
135
 
136
                    $sessionStorage = new SessionStorage();
137
                    if (isset($session['storage'])) {
138
                        $class = $session['storage'];
139
                        $sessionStorage = new $class();
140
                    }
141
 
142
 
143
 
144
 
145
 
146
                    $sessionManager = new \Laminas\Session\SessionManager();
147
                    $sessionManager->setConfig($sessionConfig);
148
                    $sessionManager->setStorage($sessionStorage);
149
 
150
                    if(!empty($config['leaderslinked.runmode.session_in_cache'])) {
151
                        $cache    = $sm->get('leaders-linked-cache');
152
                        $saveHandler= new SessionCacheHandler($cache);
153
                        $sessionManager->setSaveHandler($saveHandler);
154
                    }
155
 
156
 
157
                } else {
158
                    $sessionManager = new \Laminas\Session\SessionManager();
159
                }
160
 
161
                \Laminas\Session\Container::setDefaultManager($sessionManager);
162
                return $sessionManager;
301 www 163
            },*/
1 efrain 164
        ],
165
        'abstract_factories' => [
166
 
167
        ]
168
    ],
169
 
170
];