Esempio n. 1
0
 /**
  * Dump the results of the currently established route.
  *
  * @return void
  */
 protected function route()
 {
     // We'll call the router using the method and URI specified by
     // the developer on the CLI. If a route is found, we will not
     // run the filters, but simply dump the result.
     $route = Router::route(Request::method(), URI::current());
     if (!is_null($route)) {
         var_dump($route->response());
     } else {
         echo '404: Not Found';
     }
 }
 /**
  * Execute a controller action and return the response.
  *
  * Unlike the "execute" method, no filters will be run and the response
  * from the controller action will not be changed in any way before it
  * is returned to the consumer.
  *
  * @param  string  $method
  * @param  array   $parameters
  * @return mixed
  */
 public function response($method, $parameters = array())
 {
     // 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;
     }
     return $response;
 }
Esempio n. 3
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;
 }
Esempio n. 4
0
 /**
  * Determine if this collection's filters apply to a given method.
  *
  * @param  string  $method
  * @return bool
  */
 public function applies($method)
 {
     if (count($this->only) > 0 and !in_array($method, $this->only)) {
         return false;
     }
     if (count($this->except) > 0 and in_array($method, $this->except)) {
         return false;
     }
     $request = strtolower(Request::method());
     if (count($this->methods) > 0 and !in_array($request, $this->methods)) {
         return false;
     }
     return true;
 }
Esempio n. 5
0
});
$uri = URI::current();
$languages = Config::get('application.languages', array());
$languages[] = Config::get('application.language');
foreach ($languages as $language) {
    if (preg_match("#^{$language}(?:\$|/)#i", $uri)) {
        Config::set('application.language', $language);
        $uri = trim(substr($uri, strlen($language)), '/');
        break;
    }
}
if ($uri == '') {
    $uri = '/';
}
URI::$uri = $uri;
Request::$route = Router::route(Request::method(), $uri);
$response = Request::$route->call();
$response->render();
if (Config::get('session.driver') !== '') {
    Session::save();
}
$response->send();
Event::fire('laravel.done', array($response));
$response->foundation->finish();
/**
 * laravel\log.php
 */
class Log
{
    public static function exception($e)
    {