Module   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 2
c 2
b 0
f 1
lcom 0
cbo 0
dl 0
loc 39
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A registerAutoloaders() 0 13 1
A registerServices() 0 16 1
1
<?php
2
3
/**
4
 * architect - a PHP Framework for rapid developing
5
 *
6
 * @package  architect
7
 * @author   Baris Kalaycioglu <[email protected]>
8
 */
9
10
namespace Modules\Common;
11
12
use Phalcon\Loader;
13
use Phalcon\Mvc\View;
14
use Phalcon\DiInterface;
15
use Phalcon\Mvc\Dispatcher;
16
use Phalcon\Mvc\ModuleDefinitionInterface;
17
18
class Module implements ModuleDefinitionInterface
19
{
20
    /**
21
     * Register a specific autoloader for the module
22
     */
23
    public function registerAutoloaders(DiInterface $dependencyInjector = null)
24
    {
25
        $loader = new Loader();
26
27
        $loader->registerNamespaces(
28
            array(
29
                'Modules\Common\Controllers' => __DIR__ . '/controllers/',
30
                'Modules\Common\Models'      => __DIR__ . '/models/',
31
            )
32
        );
33
34
        $loader->register();
35
    }
36
37
    /**
38
     * Register specific services for the module
39
     */
40
    public function registerServices(DiInterface $di)
41
    {
42
        // Registering a dispatcher
43
        $di->set('dispatcher', function () {
44
            $dispatcher = new Dispatcher();
45
            $dispatcher->setDefaultNamespace("Modules\Common\Controllers");
46
            return $dispatcher;
47
        });
48
49
        $appConfig = $di->get('config');
50
        $view = $di->get('view');
51
        $view->setLayoutsDir( '_shared/');
52
        $view->setTemplateAfter($appConfig->view_layout_name);
53
        $view->setViewsDir( __DIR__ . '/views/');
54
        $di->set('view', $view);
55
    }
56
}