/** * 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'; } }
/** * Get the URI for the current request. * * @return string */ public static function uri() { return URI::current(); }
/** * Get the full URL for the current request. * * @return string */ public static function current() { return static::to(URI::current()); }
/** * Get the full URL for the current request. * * @return string */ public static function current() { return static::to(URI::current(), null, false, false); }
/** * Determine the appropriate action parameter to use for a form. * * If no action is specified, the current request URI will be used. * * @param string $action * @param bool $https * @return string */ protected static function action($action, $https) { $uri = is_null($action) ? URI::current() : $action; return HTML::entities(URL::to($uri, $https)); }
public static function to_language($language, $reset = false) { $url = $reset ? URL::home() : URL::to(URI::current()); if (!in_array($language, Config::get('application.languages'))) { return $url; } $from = '/' . Config::get('application.language') . '/'; $to = '/' . $language . '/'; return str_replace($from, $to, $url); }
| */ Router::register('*', '(:all)', function () { return Event::first('404'); }); /* |-------------------------------------------------------------------------- | Gather The URI And Locales |-------------------------------------------------------------------------- | | When routing, we'll need to grab the URI and the supported locales for | the route so we can properly set the language and route the request | to the proper end-point in the application. | */ $uri = URI::current(); $languages = Config::get('application.languages', array()); $languages[] = Config::get('application.language'); /* |-------------------------------------------------------------------------- | Set The Locale Based On The Route |-------------------------------------------------------------------------- | | If the URI starts with one of the supported languages, we will set | the default lagnauge to match that URI segment and shorten the | URI we'll pass to the router to not include the lang segment. | */ foreach ($languages as $language) { if (preg_match("#^{$language}(?:\$|/)#i", $uri)) { Config::set('application.language', $language);
/** * Get the URL to switch language, keeping the current page or not * * @param string $language The new language * @param boolean $reset Whether navigation should be reset * @return string An URL */ public static function to_language($language, $reset = false) { // Get the url to use as base $url = $reset ? URL::home() : URL::to(URI::current()); // Validate the language if (!in_array($language, Config::get('application.languages'))) { return $url; } // Get the language we're switching from and the one we're going to $from = '/' . Config::get('application.language') . '/'; $to = '/' . $language . '/'; return str_replace($from, $to, $url); }
public function search() { return Form::open(URI::current(), 'GET') . Form::text('q', null, array('class' => 'search')) . Form::close(); }