src/Http/HttpCore.php
protected function executeController($controller_esp, $uriapp = NULL) {
        if (count($controller_esp['middlewares']) > 0) {
            if ($this->executeMiddlewares($controller_esp['middlewares']) === false) {
                return;
            }
        }
        
        $dir= $this->buildDir($controller_esp);
        $class= $this->buildClass($controller_esp);
        if(!class_exists($class)){
            //Si la clase no existe intento cargarla
            if(file_exists($dir)){
                require_once $dir;
            }else{
                //Avisa que el archivo no existe
                Error::general_error('Controller Error', 'The controller ' . $controller_esp['class'] . ' dont exists');
            } 
        }
        $controller= new $class();
        //Agrego los parametros URI
        $uri_params= UrlUri::uriParams($controller_esp['url'], $uriapp);
        $dinamic_method= $uri_params['dinamic'];
        $method= $uri_params['method']; 
        $parameters= $uri_params['params'] ? $uri_params['params'] : array();
        //Analizo si hay parametros en la configuracion
        if(isset($controller_esp['properties'])){
            $this->app->dependenciesEngine->injectProperties($controller, $controller_esp['properties']);
        }       
        //Saca el metodo HTPP y en base a eso hace una llamada al metodo correspondiente
        $methodHttp= filter_input(INPUT_SERVER, 'REQUEST_METHOD');
        if($dinamic_method){
            if($method != 'index' && !(method_exists($controller, $methodHttp . '_' . $method) || method_exists($controller, $method))){
                $parameters= array_merge(array('0' => $method), $parameters);
                $method= 'index';                
            }
            if(method_exists($controller, $methodHttp . '_' . $method)){
                $method= $methodHttp . '_' . $method;
            }
        }else if(isset($controller_esp['method'])){
            $method= $controller_esp['method'];
        }else{
            $method= "do" . ucfirst(strtolower($methodHttp));
        }
        $controller->setUriParams($parameters);
        if(method_exists($controller, $method)){
            $controller->$method($this->httpRequest, $this->httpResponse);
        }else{
            Error::general_error('HTTP Method Error', "The HTTP method $method is not supported");
        }
    }
protected function executeController($controller_esp, $uriapp = NULL) {
        if (count($controller_esp['middlewares']) > 0) {
            if ($this->executeMiddlewares($controller_esp['middlewares']) === false) {
                return;
            }
        }
        
        $dir= $this->buildDir($controller_esp);
        $class= $this->buildClass($controller_esp);
        if(!class_exists($class)){
            //Si la clase no existe intento cargarla
            if(file_exists($dir)){
                require_once $dir;
            }else{
                //Avisa que el archivo no existe
                Error::general_error('Controller Error', 'The controller ' . $controller_esp['class'] . ' dont exists');
            } 
        }
        $controller= new $class();
        //Agrego los parametros URI
        $uri_params= UrlUri::uriParams($controller_esp['url'], $uriapp);
        $dinamic_method= $uri_params['dinamic'];
        $method= $uri_params['method']; 
        $parameters= $uri_params['params'] ? $uri_params['params'] : array();
        //Analizo si hay parametros en la configuracion
        if(isset($controller_esp['properties'])){
            $this->app->dependenciesEngine->injectProperties($controller, $controller_esp['properties']);
        }       
        //Saca el metodo HTPP y en base a eso hace una llamada al metodo correspondiente
        $methodHttp= filter_input(INPUT_SERVER, 'REQUEST_METHOD');
        if($dinamic_method){
            if($method != 'index' && !(method_exists($controller, $methodHttp . '_' . $method) || method_exists($controller, $method))){
                $parameters= array_merge(array('0' => $method), $parameters);
                $method= 'index';                
            }
            if(method_exists($controller, $methodHttp . '_' . $method)){
                $method= $methodHttp . '_' . $method;
            }
        }else if(isset($controller_esp['method'])){
            $method= $controller_esp['method'];
        }else{
            $method= "do" . ucfirst(strtolower($methodHttp));
        }
        $controller->setUriParams($parameters);
        if(method_exists($controller, $method)){
            $controller->$method($this->httpRequest, $this->httpResponse);
        }else{
            Error::general_error('HTTP Method Error', "The HTTP method $method is not supported");
        }
    }
protected function executeController ( $ controller_esp , $ uriapp = NULL ) { if ( count ( $ controller_esp [ 'middlewares' ] ) > 0 ) { if ( $ this -> executeMiddlewares ( $ controller_esp [ 'middlewares' ] ) === false ) { return ; } } $ dir = $ this -> buildDir ( $ controller_esp ) ; $ class = $ this -> buildClass ( $ controller_esp ) ; if ( ! class_exists ( $ class ) ) { //Si la clase no existe intento cargarla if ( file_exists ( $ dir ) ) { require_once $ dir ; } else { //Avisa que el archivo no existe Error :: general_error ( 'Controller Error' , 'The controller ' . $ controller_esp [ 'class' ] . ' dont exists' ) ; } } $ controller = new $ class ( ) ; //Agrego los parametros URI $ uri_params = UrlUri :: uriParams ( $ controller_esp [ 'url' ] , $ uriapp ) ; $ dinamic_method = $ uri_params [ 'dinamic' ] ; $ method = $ uri_params [ 'method' ] ; $ parameters = $ uri_params [ 'params' ] ? $ uri_params [ 'params' ] : array ( ) ; //Analizo si hay parametros en la configuracion if ( isset ( $ controller_esp [ 'properties' ] ) ) { $ this -> app -> dependenciesEngine -> injectProperties ( $ controller , $ controller_esp [ 'properties' ] ) ; } //Saca el metodo HTPP y en base a eso hace una llamada al metodo correspondiente $ methodHttp = filter_input ( INPUT_SERVER , 'REQUEST_METHOD' ) ; if ( $ dinamic_method ) { if ( $ method != 'index' && ! ( method_exists ( $ controller , $ methodHttp . '_' . $ method ) || method_exists ( $ controller , $ method ) ) ) { $ parameters = array_merge ( array ( '0' => $ method ) , $ parameters ) ; $ method = 'index' ; } if ( method_exists ( $ controller , $ methodHttp . '_' . $ method ) ) { $ method = $ methodHttp . '_' . $ method ; } } else if ( isset ( $ controller_esp [ 'method' ] ) ) { $ method = $ controller_esp [ 'method' ] ; } else { $ method = "do" . ucfirst ( strtolower ( $ methodHttp ) ) ; } $ controller -> setUriParams ( $ parameters ) ; if ( method_exists ( $ controller , $ method ) ) { $ controller -> $ method ( $ this -> httpRequest , $ this -> httpResponse ) ; } else { Error :: general_error ( 'HTTP Method Error' , "The HTTP method $method is not supported" ) ; } }
Ejecuta el controlador que mapeo anteriormente. Segun su definicion en la configuracion se ejecutara al estilo REST
o mediante nombre de funciones
@param array $controller_esp
@param string $uriapp
Ejecuta el controlador que mapeo anteriormente . Segun su definicion en la configuracion se ejecutara al estilo REST o mediante nombre de funciones