Controller   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 119
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 119
rs 10
c 0
b 0
f 0
wmc 8
lcom 1
cbo 1

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 1
A before_filter() 0 3 1
A after_filter() 0 3 1
A initialize() 0 3 1
A finalize() 0 3 1
A k_callback() 0 12 3
1
<?php
2
/**
3
 * KumbiaPHP web & app Framework
4
 *
5
 * LICENSE
6
 *
7
 * This source file is subject to the new BSD license that is bundled
8
 * with this package in the file LICENSE.
9
 *
10
 * @category   Kumbia
11
 * @package    Controller
12
 *
13
 * @copyright  Copyright (c) 2005 - 2019 KumbiaPHP Team (http://www.kumbiaphp.com)
14
 * @license    https://github.com/KumbiaPHP/KumbiaPHP/blob/master/LICENSE   New BSD License
15
 */
16
17
/**
18
 * Clase principal para los controladores de Kumbia
19
 *
20
 * @category   Kumbia
21
 * @package    Controller
22
 */
23
class Controller
24
{
25
26
    /**
27
     * Nombre del modulo actual
28
     *
29
     * @var string
30
     */
31
    public $module_name;
32
    /**
33
     * Nombre del controlador actual
34
     *
35
     * @var string
36
     */
37
    public $controller_name;
38
    /**
39
     * Nombre de la acción actual
40
     *
41
     * @var string
42
     */
43
    public $action_name;
44
    /**
45
     * Parámetros de la acción
46
     *
47
     * @var array
48
     */
49
    public $parameters;
50
    /**
51
     * Limita la cantidad correcta de
52
     * parametros de una action
53
     *
54
     * @var bool
55
     */
56
    public $limit_params = true;
57
    /**
58
     * Nombre del scaffold a usar
59
     *
60
     * @var string
61
     */
62
    public $scaffold = '';
63
64
    /**
65
     * Data disponble para mostrar
66
     * 
67
     * @var mixed
68
     */
69
    public $data;
70
71
    /**
72
     * Constructor
73
     *
74
     * @param array $args
75
     */
76
    public function __construct($args)
77
    {
78
        /*modulo al que pertenece el controlador*/
79
        $this->module_name = $args['module'];
80
        $this->controller_name = $args['controller'];
81
        $this->parameters = $args['parameters'];
82
        $this->action_name = $args['action'];
83
        View::select($args['action']);
84
        View::setPath($args['controller_path']);
85
    }
86
87
    /**
88
     * BeforeFilter
89
     *
90
     * @return false|null
91
     */
92
    protected function before_filter()
93
    {
94
    }
95
96
    /**
97
     * AfterFilter
98
     *
99
     * @return false|void
100
     */
101
    protected function after_filter()
102
    {
103
    }
104
105
    /**
106
     * Initialize
107
     *
108
     * @return false|void
109
     */
110
    protected function initialize()
111
    {
112
    }
113
114
    /**
115
     * Finalize
116
     *
117
     * @return false|void
118
     */
119
    protected function finalize()
120
    {
121
    }
122
123
    /**
124
     * Ejecuta los callback filter
125
     *
126
     * @param boolean $init filtros de inicio
127
     * @return false|void
128
     */
129
    final public function k_callback($init = false)
130
    {
131
        if ($init) {
132
            if ($this->initialize() !== false) {
133
                return $this->before_filter();
134
            }
135
            return false;
136
        }
137
138
        $this->after_filter();
139
        $this->finalize();
140
    }
141
}
142