-
Notifications
You must be signed in to change notification settings - Fork 614
Expand file tree
/
Copy pathservices_web.php
More file actions
73 lines (61 loc) · 1.69 KB
/
services_web.php
File metadata and controls
73 lines (61 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
declare(strict_types=1);
use Phalcon\Escaper;
use Phalcon\Flash\Direct as Flash;
use Phalcon\Mvc\Dispatcher;
use Phalcon\Mvc\Router;
use Phalcon\Session\Adapter\Stream as SessionAdapter;
use Phalcon\Session\Manager as SessionManager;
use Phalcon\Url as UrlResolver;
/**
* Registering a router
*/
$di->setShared('router', function () {
$router = new Router();
$router->setDefaultModule('frontend');
return $router;
});
/**
* The URL component is used to generate all kinds of URLs in the application
*/
$di->setShared('url', function () {
$config = $this->getConfig();
$url = new UrlResolver();
$url->setBaseUri($config->application->baseUri);
return $url;
});
/**
* Starts the session the first time some component requests the session service
*/
$di->setShared('session', function () {
$session = new SessionManager();
$files = new SessionAdapter([
'savePath' => sys_get_temp_dir(),
]);
$session->setAdapter($files);
$session->start();
return $session;
});
/**
* Register the session flash service with the Twitter Bootstrap classes
*/
$di->set('flash', function () {
$escaper = new Escaper();
$flash = new Flash($escaper);
$flash->setImplicitFlush(false);
$flash->setCssClasses([
'error' => 'alert alert-danger',
'success' => 'alert alert-success',
'notice' => 'alert alert-info',
'warning' => 'alert alert-warning'
]);
return $flash;
});
/**
* Set the default namespace for dispatcher
*/
$di->setShared('dispatcher', function() {
$dispatcher = new Dispatcher();
$dispatcher->setDefaultNamespace('@@namespace@@\Modules\Frontend\Controllers');
return $dispatcher;
});