-
-
Notifications
You must be signed in to change notification settings - Fork 317
Expand file tree
/
Copy pathModule.php
More file actions
66 lines (57 loc) · 1.61 KB
/
Module.php
File metadata and controls
66 lines (57 loc) · 1.61 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
<?php
namespace Multiple\Backend;
use Phalcon\Autoload\Loader;
use Phalcon\Di\DiInterface;
use Phalcon\Mvc\Dispatcher;
use Phalcon\Db\Adapter\Pdo\Mysql;
use Phalcon\Mvc\ModuleDefinitionInterface;
class Module implements ModuleDefinitionInterface
{
/**
* Registers the module auto-loader
*
* @param DiInterface $di
*/
public function registerAutoloaders(DiInterface $di = null)
{
$loader = new Loader();
$loader->setNamespaces(
[
"Multiple\\Backend\\Controllers" => "../apps/modules/backend/controllers/",
"Multiple\\Backend\\Models" => "../apps/modules/backend/models/",
]
);
$loader->register();
}
/**
* Registers services related to the module
*
* @param DiInterface $di
*/
public function registerServices(DiInterface $di)
{
// Registering a dispatcher
$di->set(
"dispatcher",
function () {
$dispatcher = new Dispatcher();
$dispatcher->setDefaultNamespace('Multiple\Backend\Controllers\\');
return $dispatcher;
}
);
// Set a different connection in each module
$di->set(
"db",
function () {
return new Mysql(
[
'host' => 'localhost',
'username' => 'phalcon',
'password' => 'secret',
'dbname' => 'phalcon_invo',
]
);
}
);
}
}