public function launchAction()
    {
        self::$obLevel = ob_get_level();
        
        if (php_sapi_name() != 'cli') {
            ob_start();
        }
        
        $router = $this->_router;
        $activeRoute = $router->getActiveRoute();
        
        // optionally sets the content-type
        if (isset($activeRoute['contentType'])) {
            $this->_response->setContentType($activeRoute['contentType']);
        }
        
        // optionally sets the client cache duration
        if (isset($activeRoute['cacheMinutes'])) {
            $this->_response->setCacheable($activeRoute['cacheMinutes']);
        }
        
        // flag to allow the code of the controller to be executed
        // or not if a middleware returns false
        $allowedByPreMiddleware = true;

         // handle CORS using the cors built-in middleware
        $corsPreflight = new \Nf\Middleware\Cors();
        $allowedByPreMiddleware = $corsPreflight->execute();

        // call pre middlewares defined by the active route
        if (isset($activeRoute['middlewaresPre'])) {
            foreach ($activeRoute['middlewaresPre'] as $middleware) {
                if ($allowedByPreMiddleware) {
                    $object = new $middleware();
                    $ret = $object->execute();
                    if ($ret === false) {
                        $allowedByPreMiddleware = false;
                        break;
                    }
                }
            }
            unset($middleware);
        }
        // call pre middlewares defined programatically
        if (isset($this->registeredMiddlewares[self::MIDDLEWARE_PRE])) {
            foreach ($this->registeredMiddlewares[self::MIDDLEWARE_PRE] as $middleware) {
                if ($allowedByPreMiddleware) {
                    $object = new $middleware();
                    $ret = $object->execute();
                    if ($ret === false) {
                        $allowedByPreMiddleware = false;
                        break;
                    }
                }
            }
        }
        
        if ($allowedByPreMiddleware) {
            // call the action
            call_user_func(array(
                $this->_controllerInstance,
                $this->_actionName . 'Action'
            ));
            $content = ob_get_clean();
            $this->_response->addBodyPart($content);
            
            // call post middlewares
            if (isset($activeRoute['middlewaresPost'])) {
                foreach ($activeRoute['middlewaresPost'] as $middleware) {
                    $object = new $middleware();
                    $object->execute();
                }
                unset($middleware);
            }
            // call post middlewares defined programatically, by instance
            if (isset($this->registeredMiddlewares[self::MIDDLEWARE_POST])) {
                foreach ($this->registeredMiddlewares[self::MIDDLEWARE_POST] as $middleware) {
                    $middleware->execute();
                }
            }
        }
      
    }
public function launchAction()
    {
        self::$obLevel = ob_get_level();
        
        if (php_sapi_name() != 'cli') {
            ob_start();
        }
        
        $router = $this->_router;
        $activeRoute = $router->getActiveRoute();
        
        // optionally sets the content-type
        if (isset($activeRoute['contentType'])) {
            $this->_response->setContentType($activeRoute['contentType']);
        }
        
        // optionally sets the client cache duration
        if (isset($activeRoute['cacheMinutes'])) {
            $this->_response->setCacheable($activeRoute['cacheMinutes']);
        }
        
        // flag to allow the code of the controller to be executed
        // or not if a middleware returns false
        $allowedByPreMiddleware = true;

         // handle CORS using the cors built-in middleware
        $corsPreflight = new \Nf\Middleware\Cors();
        $allowedByPreMiddleware = $corsPreflight->execute();

        // call pre middlewares defined by the active route
        if (isset($activeRoute['middlewaresPre'])) {
            foreach ($activeRoute['middlewaresPre'] as $middleware) {
                if ($allowedByPreMiddleware) {
                    $object = new $middleware();
                    $ret = $object->execute();
                    if ($ret === false) {
                        $allowedByPreMiddleware = false;
                        break;
                    }
                }
            }
            unset($middleware);
        }
        // call pre middlewares defined programatically
        if (isset($this->registeredMiddlewares[self::MIDDLEWARE_PRE])) {
            foreach ($this->registeredMiddlewares[self::MIDDLEWARE_PRE] as $middleware) {
                if ($allowedByPreMiddleware) {
                    $object = new $middleware();
                    $ret = $object->execute();
                    if ($ret === false) {
                        $allowedByPreMiddleware = false;
                        break;
                    }
                }
            }
        }
        
        if ($allowedByPreMiddleware) {
            // call the action
            call_user_func(array(
                $this->_controllerInstance,
                $this->_actionName . 'Action'
            ));
            $content = ob_get_clean();
            $this->_response->addBodyPart($content);
            
            // call post middlewares
            if (isset($activeRoute['middlewaresPost'])) {
                foreach ($activeRoute['middlewaresPost'] as $middleware) {
                    $object = new $middleware();
                    $object->execute();
                }
                unset($middleware);
            }
            // call post middlewares defined programatically, by instance
            if (isset($this->registeredMiddlewares[self::MIDDLEWARE_POST])) {
                foreach ($this->registeredMiddlewares[self::MIDDLEWARE_POST] as $middleware) {
                    $middleware->execute();
                }
            }
        }
      
    }
public function launchAction ( ) { self :: $ obLevel = ob_get_level ( ) ; if ( php_sapi_name ( ) != 'cli' ) { ob_start ( ) ; } $ router = $ this -> _router ; $ activeRoute = $ router -> getActiveRoute ( ) ; // optionally sets the content-type if ( isset ( $ activeRoute [ 'contentType' ] ) ) { $ this -> _response -> setContentType ( $ activeRoute [ 'contentType' ] ) ; } // optionally sets the client cache duration if ( isset ( $ activeRoute [ 'cacheMinutes' ] ) ) { $ this -> _response -> setCacheable ( $ activeRoute [ 'cacheMinutes' ] ) ; } // flag to allow the code of the controller to be executed // or not if a middleware returns false $ allowedByPreMiddleware = true ; // handle CORS using the cors built-in middleware $ corsPreflight = new \ Nf \ Middleware \ Cors ( ) ; $ allowedByPreMiddleware = $ corsPreflight -> execute ( ) ; // call pre middlewares defined by the active route if ( isset ( $ activeRoute [ 'middlewaresPre' ] ) ) { foreach ( $ activeRoute [ 'middlewaresPre' ] as $ middleware ) { if ( $ allowedByPreMiddleware ) { $ object = new $ middleware ( ) ; $ ret = $ object -> execute ( ) ; if ( $ ret === false ) { $ allowedByPreMiddleware = false ; break ; } } } unset ( $ middleware ) ; } // call pre middlewares defined programatically if ( isset ( $ this -> registeredMiddlewares [ self :: MIDDLEWARE_PRE ] ) ) { foreach ( $ this -> registeredMiddlewares [ self :: MIDDLEWARE_PRE ] as $ middleware ) { if ( $ allowedByPreMiddleware ) { $ object = new $ middleware ( ) ; $ ret = $ object -> execute ( ) ; if ( $ ret === false ) { $ allowedByPreMiddleware = false ; break ; } } } } if ( $ allowedByPreMiddleware ) { // call the action call_user_func ( array ( $ this -> _controllerInstance , $ this -> _actionName . 'Action' ) ) ; $ content = ob_get_clean ( ) ; $ this -> _response -> addBodyPart ( $ content ) ; // call post middlewares if ( isset ( $ activeRoute [ 'middlewaresPost' ] ) ) { foreach ( $ activeRoute [ 'middlewaresPost' ] as $ middleware ) { $ object = new $ middleware ( ) ; $ object -> execute ( ) ; } unset ( $ middleware ) ; } // call post middlewares defined programatically, by instance if ( isset ( $ this -> registeredMiddlewares [ self :: MIDDLEWARE_POST ] ) ) { foreach ( $ this -> registeredMiddlewares [ self :: MIDDLEWARE_POST ] as $ middleware ) { $ middleware -> execute ( ) ; } } } }
calls the actual action found from the routing system
calls the actual action found from the routing system