public static function call($destination, $parameters = array()) { static::references($destination, $parameters); list($bundle, $destination) = Bundle::parse($destination); Bundle::start($bundle); list($name, $method) = explode('@', $destination); $controller = static::resolve($bundle, $name); if (!is_null($route = Request::route())) { $route->controller = $name; $route->controller_action = $method; } if (is_null($controller)) { return Event::first('404'); } return $controller->execute($method, $parameters); }
/** * Call an action method on a controller. * * <code> * // Call the "show" method on the "user" controller * $response = Controller::call('user@show'); * * // Call the "user/admin" controller and pass parameters * $response = Controller::call('user.admin@profile', array($username)); * </code> * * @param string $destination * @param array $parameters * @return Response */ public static function call($destination, $parameters = array()) { static::references($destination, $parameters); list($bundle, $destination) = Bundle::parse($destination); // We will always start the bundle, just in case the developer is pointing // a route to another bundle. This allows us to lazy load the bundle and // improve speed since the bundle is not loaded on every request. Bundle::start($bundle); list($name, $method) = explode('@', $destination); $controller = static::resolve($bundle, $name); // For convenience we will set the current controller and action on the // Request's route instance so they can be easily accessed from the // application. This is sometimes useful for dynamic situations. if (!is_null($route = Request::route())) { $route->controller = $name; $route->controller_action = $method; } // If the controller could not be resolved, we're out of options and // will return the 404 error response. If we found the controller, // we can execute the requested method on the instance. if (is_null($controller)) { return Event::first('404'); } return $controller->execute($method, $parameters); }
}); $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) {