classes/Route.php
public function run(array $args, $method='get'){
      $method = strtolower($method);
      $append_echoed_text = Options::get('core.route.append_echoed_text',true);
      static::trigger('start', $this, $args, $method);

      // Call direct befores
      if ( $this->befores ) {
        // Reverse befores order
        foreach (array_reverse($this->befores) as $mw) {
          static::trigger('before', $this, $mw);
          Event::trigger('core.route.before', $this, $mw);
          ob_start();
          $mw_result  = call_user_func($mw);
          $raw_echoed = ob_get_clean();
          if ($append_echoed_text) Response::add($raw_echoed);
          if ( false  === $mw_result ) {
            return [''];
          } else {
            Response::add($mw_result);
          }
        }
      }

      $callback = (is_array($this->callback) && isset($this->callback[$method]))
                  ? $this->callback[$method]
                  : $this->callback;

      if (is_callable($callback) || is_a($callback, "View") ) {
        Response::type( Options::get('core.route.response_default_type', Response::TYPE_HTML) );

        ob_start();
        if (is_a($callback, "View")) {
          // Get the rendered view
          $view_results = (string)$callback;
        } else {
          $view_results = call_user_func_array($callback, $args);
        }
        $raw_echoed   = ob_get_clean();

        if ($append_echoed_text) Response::add($raw_echoed);
        Response::add($view_results);
      }

      // Apply afters
      if ( $this->afters ) {
        foreach ($this->afters as $mw) {
          static::trigger('after', $this, $mw);
          Event::trigger('core.route.after', $this, $mw);
          ob_start();
          $mw_result  = call_user_func($mw);
          $raw_echoed = ob_get_clean();
          if ($append_echoed_text) Response::add($raw_echoed);
          if ( false  === $mw_result ) {
            return [''];
          } else {
            Response::add($mw_result);
          }
        }
      }

      static::trigger('end', $this, $args, $method);
      Event::trigger('core.route.end', $this);

      return [Filter::with('core.route.response', Response::body())];
     }
public function run(array $args, $method='get'){
      $method = strtolower($method);
      $append_echoed_text = Options::get('core.route.append_echoed_text',true);
      static::trigger('start', $this, $args, $method);

      // Call direct befores
      if ( $this->befores ) {
        // Reverse befores order
        foreach (array_reverse($this->befores) as $mw) {
          static::trigger('before', $this, $mw);
          Event::trigger('core.route.before', $this, $mw);
          ob_start();
          $mw_result  = call_user_func($mw);
          $raw_echoed = ob_get_clean();
          if ($append_echoed_text) Response::add($raw_echoed);
          if ( false  === $mw_result ) {
            return [''];
          } else {
            Response::add($mw_result);
          }
        }
      }

      $callback = (is_array($this->callback) && isset($this->callback[$method]))
                  ? $this->callback[$method]
                  : $this->callback;

      if (is_callable($callback) || is_a($callback, "View") ) {
        Response::type( Options::get('core.route.response_default_type', Response::TYPE_HTML) );

        ob_start();
        if (is_a($callback, "View")) {
          // Get the rendered view
          $view_results = (string)$callback;
        } else {
          $view_results = call_user_func_array($callback, $args);
        }
        $raw_echoed   = ob_get_clean();

        if ($append_echoed_text) Response::add($raw_echoed);
        Response::add($view_results);
      }

      // Apply afters
      if ( $this->afters ) {
        foreach ($this->afters as $mw) {
          static::trigger('after', $this, $mw);
          Event::trigger('core.route.after', $this, $mw);
          ob_start();
          $mw_result  = call_user_func($mw);
          $raw_echoed = ob_get_clean();
          if ($append_echoed_text) Response::add($raw_echoed);
          if ( false  === $mw_result ) {
            return [''];
          } else {
            Response::add($mw_result);
          }
        }
      }

      static::trigger('end', $this, $args, $method);
      Event::trigger('core.route.end', $this);

      return [Filter::with('core.route.response', Response::body())];
     }
public function run ( array $ args , $ method = 'get' ) { $ method = strtolower ( $ method ) ; $ append_echoed_text = Options :: get ( 'core.route.append_echoed_text' , true ) ; static :: trigger ( 'start' , $ this , $ args , $ method ) ; // Call direct befores if ( $ this -> befores ) { // Reverse befores order foreach ( array_reverse ( $ this -> befores ) as $ mw ) { static :: trigger ( 'before' , $ this , $ mw ) ; Event :: trigger ( 'core.route.before' , $ this , $ mw ) ; ob_start ( ) ; $ mw_result = call_user_func ( $ mw ) ; $ raw_echoed = ob_get_clean ( ) ; if ( $ append_echoed_text ) Response :: add ( $ raw_echoed ) ; if ( false === $ mw_result ) { return [ '' ] ; } else { Response :: add ( $ mw_result ) ; } } } $ callback = ( is_array ( $ this -> callback ) && isset ( $ this -> callback [ $ method ] ) ) ? $ this -> callback [ $ method ] : $ this -> callback ; if ( is_callable ( $ callback ) || is_a ( $ callback , "View" ) ) { Response :: type ( Options :: get ( 'core.route.response_default_type' , Response :: TYPE_HTML ) ) ; ob_start ( ) ; if ( is_a ( $ callback , "View" ) ) { // Get the rendered view $ view_results = ( string ) $ callback ; } else { $ view_results = call_user_func_array ( $ callback , $ args ) ; } $ raw_echoed = ob_get_clean ( ) ; if ( $ append_echoed_text ) Response :: add ( $ raw_echoed ) ; Response :: add ( $ view_results ) ; } // Apply afters if ( $ this -> afters ) { foreach ( $ this -> afters as $ mw ) { static :: trigger ( 'after' , $ this , $ mw ) ; Event :: trigger ( 'core.route.after' , $ this , $ mw ) ; ob_start ( ) ; $ mw_result = call_user_func ( $ mw ) ; $ raw_echoed = ob_get_clean ( ) ; if ( $ append_echoed_text ) Response :: add ( $ raw_echoed ) ; if ( false === $ mw_result ) { return [ '' ] ; } else { Response :: add ( $ mw_result ) ; } } } static :: trigger ( 'end' , $ this , $ args , $ method ) ; Event :: trigger ( 'core.route.end' , $ this ) ; return [ Filter :: with ( 'core.route.response' , Response :: body ( ) ) ] ; }
Run one of the mapped callbacks to a passed HTTP Method.
@param  array  $args The arguments to be passed to the callback
@param  string $method The HTTP Method requested.
@return array The callback response.
Run one of the mapped callbacks to a passed HTTP Method .