lib/Routing/Route.php
public function action(Context $context = null)
    {
        $targetFunc = null;
        $classObject = null;
        
        // Create a dummy context if needed
        if (empty($context)) {
            $context = new Context();
        }

        // Determine target function
        if ($this->isCallable()) {
            $targetFunc = $this->getTarget();
        } else {
            $targetFunc = $this->translateToClassCallable($context);
            $classObject = $targetFunc[0];
        }

        // Route filter: before function
        if (!$this->filters->trigger(Filters::BEFORE_ROUTE, $context)) {
            return null;
        }
        
        $returnValue = null;
        $continue = true;

        // Execute a "before" function, if it is defined in the target class
        if ($classObject != null) {
            $beforeCallable = [$classObject, 'before'];

            if (is_callable($beforeCallable)) {
                $returnValue = $this->executeAction($beforeCallable, $context);

                if ($returnValue && $returnValue instanceof Response) {
                    // A respone was sent by the "before" function, stop execution
                    $continue = false;
                }
            }
        }

        if ($continue) {
            // Invoke the specified controller function or the specified callable with the appropriate params
            $returnValue = $this->executeAction($targetFunc, $context);
        }

        // Route filter: After function
        $this->filters->trigger(Filters::AFTER_ROUTE, $context);
        return $returnValue;
    }
public function action(Context $context = null)
    {
        $targetFunc = null;
        $classObject = null;
        
        // Create a dummy context if needed
        if (empty($context)) {
            $context = new Context();
        }

        // Determine target function
        if ($this->isCallable()) {
            $targetFunc = $this->getTarget();
        } else {
            $targetFunc = $this->translateToClassCallable($context);
            $classObject = $targetFunc[0];
        }

        // Route filter: before function
        if (!$this->filters->trigger(Filters::BEFORE_ROUTE, $context)) {
            return null;
        }
        
        $returnValue = null;
        $continue = true;

        // Execute a "before" function, if it is defined in the target class
        if ($classObject != null) {
            $beforeCallable = [$classObject, 'before'];

            if (is_callable($beforeCallable)) {
                $returnValue = $this->executeAction($beforeCallable, $context);

                if ($returnValue && $returnValue instanceof Response) {
                    // A respone was sent by the "before" function, stop execution
                    $continue = false;
                }
            }
        }

        if ($continue) {
            // Invoke the specified controller function or the specified callable with the appropriate params
            $returnValue = $this->executeAction($targetFunc, $context);
        }

        // Route filter: After function
        $this->filters->trigger(Filters::AFTER_ROUTE, $context);
        return $returnValue;
    }
public function action ( Context $ context = null ) { $ targetFunc = null ; $ classObject = null ; // Create a dummy context if needed if ( empty ( $ context ) ) { $ context = new Context ( ) ; } // Determine target function if ( $ this -> isCallable ( ) ) { $ targetFunc = $ this -> getTarget ( ) ; } else { $ targetFunc = $ this -> translateToClassCallable ( $ context ) ; $ classObject = $ targetFunc [ 0 ] ; } // Route filter: before function if ( ! $ this -> filters -> trigger ( Filters :: BEFORE_ROUTE , $ context ) ) { return null ; } $ returnValue = null ; $ continue = true ; // Execute a "before" function, if it is defined in the target class if ( $ classObject != null ) { $ beforeCallable = [ $ classObject , 'before' ] ; if ( is_callable ( $ beforeCallable ) ) { $ returnValue = $ this -> executeAction ( $ beforeCallable , $ context ) ; if ( $ returnValue && $ returnValue instanceof Response ) { // A respone was sent by the "before" function, stop execution $ continue = false ; } } } if ( $ continue ) { // Invoke the specified controller function or the specified callable with the appropriate params $ returnValue = $ this -> executeAction ( $ targetFunc , $ context ) ; } // Route filter: After function $ this -> filters -> trigger ( Filters :: AFTER_ROUTE , $ context ) ; return $ returnValue ; }
Executes this route's action.

@param Context $context
@throws RoutingException For unsupported or invalid action configurations.
@throws \Exception If an Exception is raised during the route's action, and no onException filter is registered, the Exception will be rethrown here.
@return mixed Action return value
Executes this route s action .