src/Http/HttpCore.php
protected function executeMiddlewares($middlewares){
        //Analizo los filtros y los aplico en caso de que corresponda
        $middlewaresDefinition = $this->app->context->getMiddlewaresDefinition();
        foreach ($middlewares as $middlewareName) {
            if (! isset($middlewaresDefinition[$middlewareName])) {
                Error::general_error('Middleware Error', 'The middleware ' . $middlewareName . ' dont exists');
            }
            
            $middleware = $middlewaresDefinition[$middlewareName];
            
            $dir = $this->buildDir($middleware, 'middlewares');
            $class = $this->buildClass($middleware);
            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('Middleware Error', 'The middleware ' . $middleware['class'] . ' dont exists');
                } 
            }
            $middlewareIns= new $class();
            //Analizo si hay parametros en la configuracion
            if(isset($middleware['properties'])){
                $this->app->dependenciesEngine->injectProperties($middlewareIns, $middleware['properties']);
            }
            //Analiza si existe el metodo filtrar
            if(method_exists($middlewareIns, 'handle')){
                $rta= $middlewareIns->handle($this->httpRequest, $this->httpResponse);
                if($rta === false){
                    return false;
                }
            }
            else{
                Error::general_error('Middleware Error', 'The middleware ' . $middleware['class'] . ' dont implement the method handle()');
            }
        }
    }
protected function executeMiddlewares($middlewares){
        //Analizo los filtros y los aplico en caso de que corresponda
        $middlewaresDefinition = $this->app->context->getMiddlewaresDefinition();
        foreach ($middlewares as $middlewareName) {
            if (! isset($middlewaresDefinition[$middlewareName])) {
                Error::general_error('Middleware Error', 'The middleware ' . $middlewareName . ' dont exists');
            }
            
            $middleware = $middlewaresDefinition[$middlewareName];
            
            $dir = $this->buildDir($middleware, 'middlewares');
            $class = $this->buildClass($middleware);
            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('Middleware Error', 'The middleware ' . $middleware['class'] . ' dont exists');
                } 
            }
            $middlewareIns= new $class();
            //Analizo si hay parametros en la configuracion
            if(isset($middleware['properties'])){
                $this->app->dependenciesEngine->injectProperties($middlewareIns, $middleware['properties']);
            }
            //Analiza si existe el metodo filtrar
            if(method_exists($middlewareIns, 'handle')){
                $rta= $middlewareIns->handle($this->httpRequest, $this->httpResponse);
                if($rta === false){
                    return false;
                }
            }
            else{
                Error::general_error('Middleware Error', 'The middleware ' . $middleware['class'] . ' dont implement the method handle()');
            }
        }
    }
protected function executeMiddlewares ( $ middlewares ) { //Analizo los filtros y los aplico en caso de que corresponda $ middlewaresDefinition = $ this -> app -> context -> getMiddlewaresDefinition ( ) ; foreach ( $ middlewares as $ middlewareName ) { if ( ! isset ( $ middlewaresDefinition [ $ middlewareName ] ) ) { Error :: general_error ( 'Middleware Error' , 'The middleware ' . $ middlewareName . ' dont exists' ) ; } $ middleware = $ middlewaresDefinition [ $ middlewareName ] ; $ dir = $ this -> buildDir ( $ middleware , 'middlewares' ) ; $ class = $ this -> buildClass ( $ middleware ) ; 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 ( 'Middleware Error' , 'The middleware ' . $ middleware [ 'class' ] . ' dont exists' ) ; } } $ middlewareIns = new $ class ( ) ; //Analizo si hay parametros en la configuracion if ( isset ( $ middleware [ 'properties' ] ) ) { $ this -> app -> dependenciesEngine -> injectProperties ( $ middlewareIns , $ middleware [ 'properties' ] ) ; } //Analiza si existe el metodo filtrar if ( method_exists ( $ middlewareIns , 'handle' ) ) { $ rta = $ middlewareIns -> handle ( $ this -> httpRequest , $ this -> httpResponse ) ; if ( $ rta === false ) { return false ; } } else { Error :: general_error ( 'Middleware Error' , 'The middleware ' . $ middleware [ 'class' ] . ' dont implement the method handle()' ) ; } } }
Se ejecutan los middlewares que se pasan como parametro
@param array[string] $filters
@param string $uriapp
Se ejecutan los middlewares que se pasan como parametro