-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTask.php
More file actions
executable file
·60 lines (49 loc) · 1.71 KB
/
Task.php
File metadata and controls
executable file
·60 lines (49 loc) · 1.71 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
<?php
namespace Instcar\Server;
class Task
{
public function registerAutoloaders()
{
$loader = new \Phalcon\Loader();
$loader->registerNamespaces(array(
'Instcar\Server\Tasks' => __DIR__.'/tasks/',
'Instcar\Server\Models' => __DIR__.'/models/',
'Instcar\Server\Logics' => __DIR__.'/logics/',
'Instcar\Server\Plugins' => __DIR__.'/plugins',
))->register();
}
/**
*
* Register the services here to make them module-specific
*
*/
public function registerServices($di)
{
// get bootstrap obj
$bootstrap = $di->get('bootstrap');
// get config class name
$confClass = $bootstrap->getConfClass();
// module config
$mConfPath = __DIR__.'/confs/'.PHALCON_ENV.'.'.PHALCON_CONF_TYPE;
if(!is_file($mConfPath)) {
throw new \Phalcon\Config\Exception("Module config file not exist, file position: {$mConfPath}");
}
if(PHALCON_CONF_TYPE == 'ini') {
$mConfig = new $confClass($mConfPath);
} else if(PHALCON_CONF_TYPE == 'php') {
$mConfig = new $confClass(require_once($mConfPath));
}
// global config
$gConfig = $di->get('config');
// merge module config and global config, module's will override global's
$gConfig->merge($mConfig);
// set config back
$di->set('config', $gConfig);
// Registering a dispatcher
$di->set('dispatcher', function () {
$dispatcher = new \Phalcon\CLI\Dispatcher();
$dispatcher->setDefaultNamespace("Instcar\Server\Tasks\\");
return $dispatcher;
});
}
}