コード例 #1
0
ファイル: LaravelTestCase.php プロジェクト: jknox12/mirror
 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
ファイル: route.php プロジェクト: nenoraith/sowcomposer
 /**
  * Call a given route and return the route's response.
  *
  * @return Response
  */
 public function call()
 {
     // 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).
     $response = Filter::run($this->filters('before'), array(), true);
     if (is_null($response)) {
         $response = $this->response();
     }
     // We always return a Response instance from the route calls, so
     // we'll use the prepare method on the Response class to make
     // sure we have a valid Response instance.
     $response = Response::prepare($response);
     Filter::run($this->filters('after'), array($response));
     return $response;
 }
コード例 #3
0
 /**
  * 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
ファイル: route.php プロジェクト: nshontz/laravel-blog
 /**
  * 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
ファイル: laravel.php プロジェクト: jknox12/mirror
 */
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
ファイル: controller.php プロジェクト: nshontz/laravel-blog
 /**
  * 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
 public function call()
 {
     $response = Filter::run($this->filters('before'), array(), true);
     if (is_null($response)) {
         $response = $this->response();
     }
     $response = Response::prepare($response);
     Filter::run($this->filters('after'), array(&$response));
     return $response;
 }