示例#1
0
 private function doRequest($URI, $data = [])
 {
     Input::$input = $data;
     Laravel\Routing\Filter::register(require APP_PATH . 'filters' . EXT);
     $loader = new Laravel\Routing\Loader(APP_PATH, ROUTE_PATH);
     $router = new Laravel\Routing\Router($loader, CONTROLLER_PATH);
     IoC::instance('laravel.routing.router', $router);
     Laravel\Request::$route = $router->route(Laravel\Request::method(), Laravel\URI::current());
     if (!is_null(Request::$route)) {
         $response = Request::$route->call();
     } else {
         Laravel\Routing\Filter::run(['before'], [], true);
         $response = Laravel\Response::json(['msg' => 'Not found'], 404);
         \Laravel\Routing\Filter::run(['after'], [$response], true);
     }
     ob_start();
     $response->send();
     $output = ob_get_contents();
     ob_end_clean();
     return $output;
 }
示例#2
0
 /**
  * Register a route filter.
  *
  * @param  string  $name
  * @param  mixed   $callback
  * @return void
  */
 public static function filter($name, $callback)
 {
     Filter::register($name, $callback);
 }
 /**
  * Execute a controller method with the given parameters.
  *
  * @param  string    $method
  * @param  array     $parameters
  * @return Response
  */
 public function execute($method, $parameters = array())
 {
     $filters = $this->filters('before', $method);
     // Again, as was the case with route closures, if the controller "before"
     // filters return a response, it will be considered the response to the
     // request and the controller method will not be used.
     $response = Filter::run($filters, array(), true);
     if (is_null($response)) {
         $this->before();
         $response = $this->response($method, $parameters);
     }
     $response = Response::prepare($response);
     // The "after" function on the controller is simply a convenient hook
     // so the developer can work on the response before it's returned to
     // the browser. This is useful for templating, etc.
     $this->after($response);
     Filter::run($this->filters('after', $method), array($response));
     return $response;
 }
示例#4
0
 /**
  * Call a given route and return the route's response.
  *
  * @return Response
  */
 public function call()
 {
     // Since "before" filters can halt the request cycle, we will return
     // any response from the before filters. Allowing filters to halt the
     // request cycle makes tasks like authorization convenient.
     //
     // The route is responsible for running the global filters, and any
     // filters defined on the route itself. Since all incoming requests
     // come through a route (either defined or ad-hoc), it makes sense
     // to let the route handle the global filters. If the route uses
     // a controller, the controller will only call its own filters.
     $before = array_merge(array('before'), $this->filters('before'));
     $response = Filter::run($before, array(), true);
     if (is_null($response) and !is_null($response = $this->response())) {
         if ($response instanceof Delegate) {
             $response = Controller::call($response->destination, $this->parameters);
         }
     }
     if (!$response instanceof Response) {
         $response = new Response($response);
     }
     // Stringify the response. We need to force the response to be
     // stringed before closing the session, since the developer may
     // be using the session within their views, so we cannot age
     // the session data until the view is rendered.
     $response->content = $response->render();
     $filters = array_merge($this->filters('after'), array('after'));
     Filter::run($filters, array($response));
     return $response;
 }
示例#5
0
 */
unset($input[Request::spoofer]);
Input::$input = $input;
//Compatibility hack
set_log4php_env('ls_log_file', \Config::get('env.log_path') . '/content.log');
\Logger::configure(\Config::get('log4php'));
/**
 * Route the request to the proper route in the application. If a
 * route is found, the route will be called with the current request
 * instance. If no route is found, the 404 response will be returned
 * to the browser.
 */
Routing\Filter::register(require APP_PATH . 'filters' . EXT);
$loader = new Routing\Loader(APP_PATH, ROUTE_PATH);
$router = new Routing\Router($loader, CONTROLLER_PATH);
IoC::instance('laravel.routing.router', $router);
Request::$route = $router->route(Request::method(), URI::current());
if (!is_null(Request::$route)) {
    $new_relic->name_transaction(Request::$route->key);
    try {
        $response = Request::$route->call();
    } catch (\Exception $e) {
        $handler($e);
    }
} else {
    $new_relic->name_transaction('404');
    \Laravel\Routing\Filter::run(array('before'), array(), true);
    $response = \Response::json(['msg' => 'Not found'], 404);
    \Laravel\Routing\Filter::run(array('after'), array($response), true);
}
$response->send();
示例#6
0
 /**
  * Execute a controller method with the given parameters.
  *
  * @param  string    $method
  * @param  array     $parameters
  * @return Response
  */
 public function execute($method, $parameters = array())
 {
     // Again, as was the case with route closures, if the controller
     // "before" filters return a response, it will be considered the
     // response to the request and the controller method will not be
     // used to handle the request to the application.
     $response = Filter::run($this->filters('before', $method), array(), true);
     if (is_null($response)) {
         // The developer may mark the controller as being "RESTful" which
         // indicates that the controller actions are prefixed with the
         // HTTP verb they respond to rather than the word "action".
         if ($this->restful) {
             $action = strtolower(Request::method()) . '_' . $method;
         } else {
             $action = "action_{$method}";
         }
         $response = call_user_func_array(array($this, $action), $parameters);
         // If the controller has specified a layout view. The response
         // returned by the controller method will be bound to that view
         // and the layout will be considered the response.
         if (is_null($response) and !is_null($this->layout)) {
             $response = $this->layout;
         }
     }
     if (!$response instanceof Response) {
         $response = new Response($response);
     }
     // Stringify the response. We need to force the response to be
     // stringed before closing the session, since the developer may
     // be using the session within their views, so we cannot age
     // the session data until the view is rendered.
     $response->content = $response->render();
     Filter::run($this->filters('after', $method), array($response));
     return $response;
 }
示例#7
0
 /**
  * Create a new filter collection instance.
  *
  * @param  string|array  $filters
  * @param  mixed         $parameters
  * @return void
  */
 public function __construct($filters, $parameters = null)
 {
     $this->parameters = $parameters;
     $this->filters = Filter::parse($filters);
 }
示例#8
0
 /**
  * Create a new filter collection instance.
  *
  * @param  string        $name
  * @param  string|array  $filters
  */
 public function __construct($name, $filters)
 {
     $this->name = $name;
     $this->filters = Filter::parse($filters);
 }