@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | try { |
| 128 | 128 | $reflectionMethod = new ReflectionMethod($cont, $cont->action_name); |
| 129 | 129 | } catch (ReflectionException $e) { |
| 130 | - throw new KumbiaException($cont->action_name, 'no_action');//TODO: enviar a un método del controller |
|
| 130 | + throw new KumbiaException($cont->action_name, 'no_action'); //TODO: enviar a un método del controller |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | //k_callback y __constructor metodo reservado |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | try { |
| 147 | 147 | $reflectionMethod->invokeArgs($cont, $cont->parameters); |
| 148 | 148 | } catch (ReflectionException $e) { |
| 149 | - throw new KumbiaException(null, 'no_action');//TODO: mejor no_public |
|
| 149 | + throw new KumbiaException(null, 'no_action'); //TODO: mejor no_public |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | //Corre los filtros after y finalize |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | * |
| 162 | 162 | * @return boolean En producción y cache de view |
| 163 | 163 | */ |
| 164 | - public static function cache($time, $type='view', $group='kumbia.view') |
|
| 164 | + public static function cache($time, $type = 'view', $group = 'kumbia.view') |
|
| 165 | 165 | { |
| 166 | 166 | if ($time === FALSE) { //TODO borrar cache |
| 167 | 167 | self::$_cache['type'] = FALSE; |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | $file = APP_PATH . 'views/' . self::getPath(); |
| 200 | 200 | //Si no existe el view y es scaffold |
| 201 | 201 | if (!is_file($file) && ($scaffold = self::$_controller->scaffold)) { |
| 202 | - $file = APP_PATH . "views/_shared/scaffolds/$scaffold/".self::$_view.'.phtml'; |
|
| 202 | + $file = APP_PATH . "views/_shared/scaffolds/$scaffold/" . self::$_view . '.phtml'; |
|
| 203 | 203 | } |
| 204 | 204 | return $file; |
| 205 | 205 | } |
@@ -309,7 +309,7 @@ discard block |
||
| 309 | 309 | * @return string |
| 310 | 310 | * @throw KumbiaException |
| 311 | 311 | */ |
| 312 | - public static function partial($partial, $__time='', $params=NULL, $group ='kumbia.partials') |
|
| 312 | + public static function partial($partial, $__time = '', $params = NULL, $group = 'kumbia.partials') |
|
| 313 | 313 | { |
| 314 | 314 | if (PRODUCTION && $__time && !Cache::driver()->start($__time, $partial, $group)) { |
| 315 | 315 | return; |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | $__file = CORE_PATH . "views/partials/$partial.phtml"; |
| 324 | 324 | } |
| 325 | 325 | |
| 326 | - if($params){ |
|
| 326 | + if ($params) { |
|
| 327 | 327 | if (is_string($params)) { |
| 328 | 328 | $params = Util::getParams(explode(',', $params)); |
| 329 | 329 | } |
@@ -351,7 +351,7 @@ discard block |
||
| 351 | 351 | */ |
| 352 | 352 | public static function getVar($var = '') |
| 353 | 353 | { |
| 354 | - if(!$var) return get_object_vars(self::$_controller); |
|
| 354 | + if (!$var) return get_object_vars(self::$_controller); |
|
| 355 | 355 | |
| 356 | 356 | return isset(self::$_controller->$var) ? self::$_controller->$var : NULL; |
| 357 | 357 | } |
@@ -136,8 +136,9 @@ discard block |
||
| 136 | 136 | */ |
| 137 | 137 | public static function getPath() |
| 138 | 138 | { |
| 139 | - if (self::$_response) |
|
| 140 | - return self::$_path . self::$_view . '.' . self::$_response . '.phtml'; |
|
| 139 | + if (self::$_response) { |
|
| 140 | + return self::$_path . self::$_view . '.' . self::$_response . '.phtml'; |
|
| 141 | + } |
|
| 141 | 142 | |
| 142 | 143 | return self::$_path . self::$_view . '.phtml'; |
| 143 | 144 | } |
@@ -224,8 +225,9 @@ discard block |
||
| 224 | 225 | */ |
| 225 | 226 | public static function render(Controller $controller) |
| 226 | 227 | { |
| 227 | - if (!self::$_view && !self::$_template) |
|
| 228 | - return ob_end_flush(); |
|
| 228 | + if (!self::$_view && !self::$_template) { |
|
| 229 | + return ob_end_flush(); |
|
| 230 | + } |
|
| 229 | 231 | |
| 230 | 232 | // Guarda el controlador |
| 231 | 233 | self::$_controller = $controller; |
@@ -253,8 +255,9 @@ discard block |
||
| 253 | 255 | ob_start(); |
| 254 | 256 | |
| 255 | 257 | // carga la vista |
| 256 | - if (!include self::getView()) |
|
| 257 | - throw new KumbiaException('Vista "' . self::getPath() . '" no encontrada', 'no_view'); |
|
| 258 | + if (!include self::getView()) { |
|
| 259 | + throw new KumbiaException('Vista "' . self::getPath() . '" no encontrada', 'no_view'); |
|
| 260 | + } |
|
| 258 | 261 | |
| 259 | 262 | // si esta en produccion y se cachea la vista |
| 260 | 263 | self::saveCache('view'); |
@@ -274,8 +277,9 @@ discard block |
||
| 274 | 277 | ob_start(); |
| 275 | 278 | |
| 276 | 279 | // carga el template |
| 277 | - if (!include APP_PATH . "views/_shared/templates/$__template.phtml") |
|
| 278 | - throw new KumbiaException("Template $__template no encontrado"); |
|
| 280 | + if (!include APP_PATH . "views/_shared/templates/$__template.phtml") { |
|
| 281 | + throw new KumbiaException("Template $__template no encontrado"); |
|
| 282 | + } |
|
| 279 | 283 | |
| 280 | 284 | // si esta en produccion y se cachea template |
| 281 | 285 | self::saveCache('template'); |
@@ -351,7 +355,9 @@ discard block |
||
| 351 | 355 | */ |
| 352 | 356 | public static function getVar($var = '') |
| 353 | 357 | { |
| 354 | - if(!$var) return get_object_vars(self::$_controller); |
|
| 358 | + if(!$var) { |
|
| 359 | + return get_object_vars(self::$_controller); |
|
| 360 | + } |
|
| 355 | 361 | |
| 356 | 362 | return isset(self::$_controller->$var) ? self::$_controller->$var : NULL; |
| 357 | 363 | } |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | if (!class_exists($Model, FALSE)) { |
| 77 | 77 | //Carga la clase |
| 78 | 78 | if (!include APP_PATH . "models/$model.php") { |
| 79 | - throw new KumbiaException($model,'no_model'); |
|
| 79 | + throw new KumbiaException($model, 'no_model'); |
|
| 80 | 80 | } |
| 81 | 81 | } |
| 82 | 82 | return new $Model($params); |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | //Si esta cargada continua con la siguiente clase |
| 97 | 97 | if (class_exists($Model, FALSE)) continue; |
| 98 | 98 | if (!include APP_PATH . "models/$model.php") { |
| 99 | - throw new KumbiaException($model,'no_model'); |
|
| 99 | + throw new KumbiaException($model, 'no_model'); |
|
| 100 | 100 | } |
| 101 | 101 | } |
| 102 | 102 | } |
@@ -94,7 +94,9 @@ |
||
| 94 | 94 | foreach ($args as $model) { |
| 95 | 95 | $Model = Util::camelcase(basename($model)); |
| 96 | 96 | //Si esta cargada continua con la siguiente clase |
| 97 | - if (class_exists($Model, FALSE)) continue; |
|
| 97 | + if (class_exists($Model, FALSE)) { |
|
| 98 | + continue; |
|
| 99 | + } |
|
| 98 | 100 | if (!include APP_PATH . "models/$model.php") { |
| 99 | 101 | throw new KumbiaException($model,'no_model'); |
| 100 | 102 | } |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | */ |
| 20 | 20 | |
| 21 | 21 | // @see Util |
| 22 | -require CORE_PATH.'kumbia/util.php'; |
|
| 22 | +require CORE_PATH . 'kumbia/util.php'; |
|
| 23 | 23 | |
| 24 | 24 | // Autocarga de clases |
| 25 | 25 | function kumbia_autoload($class) |
@@ -27,12 +27,12 @@ discard block |
||
| 27 | 27 | // Optimizando carga |
| 28 | 28 | static $classes; |
| 29 | 29 | if (!isset($classes)) { |
| 30 | - $classes = array ( |
|
| 31 | - 'ActiveRecord' => APP_PATH.'libs/active_record.php', |
|
| 32 | - 'Load' => CORE_PATH.'kumbia/load.php', |
|
| 33 | - 'KumbiaException' => CORE_PATH.'kumbia/kumbia_exception.php', |
|
| 34 | - 'KumbiaRouter' => CORE_PATH.'kumbia/kumbia_router.php', |
|
| 35 | - 'KumbiaFacade' => CORE_PATH.'kumbia/kumbia_facade.php' |
|
| 30 | + $classes = array( |
|
| 31 | + 'ActiveRecord' => APP_PATH . 'libs/active_record.php', |
|
| 32 | + 'Load' => CORE_PATH . 'kumbia/load.php', |
|
| 33 | + 'KumbiaException' => CORE_PATH . 'kumbia/kumbia_exception.php', |
|
| 34 | + 'KumbiaRouter' => CORE_PATH . 'kumbia/kumbia_router.php', |
|
| 35 | + 'KumbiaFacade' => CORE_PATH . 'kumbia/kumbia_facade.php' |
|
| 36 | 36 | ); |
| 37 | 37 | } |
| 38 | 38 | if (isset($classes[$class])) { |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | function kumbia_autoload_vendor($class) |
| 66 | 66 | { |
| 67 | 67 | //Autoload PSR0 |
| 68 | - $psr0 = dirname(CORE_PATH).'/vendor/'.str_replace(array('_', '\\'), DIRECTORY_SEPARATOR, $class).'.php'; |
|
| 68 | + $psr0 = dirname(CORE_PATH) . '/vendor/' . str_replace(array('_', '\\'), DIRECTORY_SEPARATOR, $class) . '.php'; |
|
| 69 | 69 | if (is_file($psr0)) { |
| 70 | 70 | include $psr0; |
| 71 | 71 | } |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | $urlItems = explode('/', trim($url, '/')); |
| 41 | 41 | |
| 42 | 42 | // El primer parametro de la url es un módulo? |
| 43 | - if (is_dir(APP_PATH."controllers/$urlItems[0]")) { |
|
| 43 | + if (is_dir(APP_PATH . "controllers/$urlItems[0]")) { |
|
| 44 | 44 | $router['module'] = $urlItems[0]; |
| 45 | 45 | |
| 46 | 46 | // Si no hay mas parametros sale |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | // Si existe una ruta con el comodin * crea la nueva ruta |
| 92 | 92 | foreach ($routes as $key => $val) { |
| 93 | 93 | if ($key == '/*') { |
| 94 | - return rtrim($val, '*').$url; |
|
| 94 | + return rtrim($val, '*') . $url; |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | if (strripos($key, '*', -1)) { |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | throw new KumbiaException(null, 'no_controller'); |
| 116 | 116 | } |
| 117 | 117 | //Asigna el controlador activo |
| 118 | - $app_controller = Util::camelcase($controller).'Controller'; |
|
| 118 | + $app_controller = Util::camelcase($controller) . 'Controller'; |
|
| 119 | 119 | return new $app_controller($param); |
| 120 | 120 | } |
| 121 | 121 | } |
@@ -87,14 +87,14 @@ discard block |
||
| 87 | 87 | $tpl = 'views/templates/exception.phtml'; |
| 88 | 88 | } |
| 89 | 89 | //Fix problem with action name in REST |
| 90 | - $action = $e->getMessage() ? $e->getMessage() : $action; |
|
| 90 | + $action = $e->getMessage() ? $e->getMessage() : $action; |
|
| 91 | 91 | |
| 92 | 92 | include CORE_PATH . "views/errors/{$view}.phtml"; |
| 93 | 93 | |
| 94 | 94 | $content = ob_get_clean(); |
| 95 | 95 | |
| 96 | 96 | // termina los buffers abiertos |
| 97 | - while (ob_get_level ()) { |
|
| 97 | + while (ob_get_level()) { |
|
| 98 | 98 | ob_end_clean(); |
| 99 | 99 | } |
| 100 | 100 | include CORE_PATH . $tpl; |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | * */ |
| 106 | 106 | private static function setHeader($e) |
| 107 | 107 | { |
| 108 | - if (isset($e->view) && in_array($e->view, self::$view404)){ |
|
| 108 | + if (isset($e->view) && in_array($e->view, self::$view404)) { |
|
| 109 | 109 | header('HTTP/1.1 404 Not Found'); |
| 110 | 110 | return; |
| 111 | 111 | } |
@@ -18,14 +18,14 @@ discard block |
||
| 18 | 18 | * @license http://wiki.kumbiaphp.com/Licencia New BSD License |
| 19 | 19 | */ |
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * Clase principal para el manejo de excepciones |
|
| 23 | - * |
|
| 24 | - * @category Kumbia |
|
| 25 | - * @package Core |
|
| 26 | - */ |
|
| 27 | - abstract class KumbiaFacade |
|
| 28 | - { |
|
| 21 | + /** |
|
| 22 | + * Clase principal para el manejo de excepciones |
|
| 23 | + * |
|
| 24 | + * @category Kumbia |
|
| 25 | + * @package Core |
|
| 26 | + */ |
|
| 27 | + abstract class KumbiaFacade |
|
| 28 | + { |
|
| 29 | 29 | protected static $providers = []; |
| 30 | 30 | |
| 31 | 31 | |
@@ -79,4 +79,4 @@ discard block |
||
| 79 | 79 | } |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - } |
|
| 82 | + } |
|
@@ -34,21 +34,21 @@ discard block |
||
| 34 | 34 | * @param Array $p key/value array with providers |
| 35 | 35 | * @return void |
| 36 | 36 | */ |
| 37 | - public static function providers(Array $p){ |
|
| 37 | + public static function providers(Array $p) { |
|
| 38 | 38 | self::$providers = $p; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | /** |
| 42 | 42 | * Getter for the alias of the component |
| 43 | 43 | */ |
| 44 | - protected static function getAlias(){ |
|
| 44 | + protected static function getAlias() { |
|
| 45 | 45 | throw new RuntimeException('Not implement'); |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | |
| 49 | 49 | protected static function getInstance($name) |
| 50 | 50 | { |
| 51 | - return isset(self::$providers[$name])?self::$providers[$name]:null; |
|
| 51 | + return isset(self::$providers[$name]) ? self::$providers[$name] : null; |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | /** |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | public static function __callStatic($method, $args) |
| 64 | 64 | { |
| 65 | 65 | $instance = self::getInstance(static::getAlias()); |
| 66 | - if (! $instance) { |
|
| 66 | + if (!$instance) { |
|
| 67 | 67 | throw new RuntimeException('A facade root has not been set.'); |
| 68 | 68 | } |
| 69 | 69 | |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | public static function get($var) |
| 53 | 53 | { |
| 54 | 54 | $namespaces = explode('.', $var); |
| 55 | - if (! isset(self::$vars[$namespaces[0]])) { |
|
| 55 | + if (!isset(self::$vars[$namespaces[0]])) { |
|
| 56 | 56 | self::load($namespaces[0]); |
| 57 | 57 | } |
| 58 | 58 | switch (count($namespaces)) { |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | return isset(self::$vars[$namespaces[0]]) ? self::$vars[$namespaces[0]] : null; |
| 67 | 67 | |
| 68 | 68 | default: |
| 69 | - trigger_error('Máximo 3 niveles en Config::get(fichero.sección.variable), pedido: '. $var); |
|
| 69 | + trigger_error('Máximo 3 niveles en Config::get(fichero.sección.variable), pedido: ' . $var); |
|
| 70 | 70 | } |
| 71 | 71 | } |
| 72 | 72 | /** |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | self::$vars[$namespaces[0]] = $value; |
| 104 | 104 | break; |
| 105 | 105 | default: |
| 106 | - trigger_error('Máximo 3 niveles en Config::set(fichero.sección.variable), pedido: '. $var); |
|
| 106 | + trigger_error('Máximo 3 niveles en Config::set(fichero.sección.variable), pedido: ' . $var); |
|
| 107 | 107 | } |
| 108 | 108 | } |
| 109 | 109 | |
@@ -117,7 +117,7 @@ |
||
| 117 | 117 | * @param string $file nombre del archivo a añadir |
| 118 | 118 | * @param array $dependencies archivos que son requisito del archivo a añadir |
| 119 | 119 | */ |
| 120 | - public static function add( $file, $dependencies=array() ) |
|
| 120 | + public static function add($file, $dependencies = array()) |
|
| 121 | 121 | { |
| 122 | 122 | self::$_js[$file] = $file; |
| 123 | 123 | foreach ($dependencies as $file) self::$_dependencies[$file] = $file; |
@@ -120,7 +120,9 @@ |
||
| 120 | 120 | public static function add( $file, $dependencies=array() ) |
| 121 | 121 | { |
| 122 | 122 | self::$_js[$file] = $file; |
| 123 | - foreach ($dependencies as $file) self::$_dependencies[$file] = $file; |
|
| 123 | + foreach ($dependencies as $file) { |
|
| 124 | + self::$_dependencies[$file] = $file; |
|
| 125 | + } |
|
| 124 | 126 | } |
| 125 | 127 | |
| 126 | 128 | /** |