/** * remove the one time GET parameters from further URIs * * @param array $keys one time parameters */ public static function strip_one_time_params(array $keys) { foreach ( $keys as $key ) { if (isset(self::$query[$key])) unset(self::$query[$key]); } // if all elements are unset, the array behaves not as an array anymore if (!count(self::$query)) self::$query = array(); self::$uri = self::build(self::$query); }
public static function current() { if (!is_null(self::$uri)) { return self::$uri; } $uri = trim(Request::pathInfo(), "/"); $uri = $uri ? $uri : "/"; self::$uri = $uri; $segments = array_diff(explode("/", trim($uri, "/")), array("")); if (array_get($segments, 0) == "manager") { self::$isManager = true; array_shift($segments); } self::$segments = $segments; return $uri; }
/** * Test the URL::to_language method. * * @group laravel */ public function testToLanguageMethodGeneratesURLsToDifferentLanguage() { URI::$uri = 'foo/bar'; Config::set('application.languages', array('sp', 'fr')); Config::set('application.language', 'sp'); $this->assertEquals('http://localhost/index.php/fr/foo/bar', URL::to_language('fr')); $this->assertEquals('http://localhost/index.php/fr/', URL::to_language('fr', true)); Config::set('application.index', ''); $this->assertEquals('http://localhost/fr/foo/bar', URL::to_language('fr')); $this->assertEquals('http://localhost/sp/foo/bar', URL::to_language('en')); }
| 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 (starts_with($uri, $language)) { Config::set('application.language', $language); $uri = trim(substr($uri, strlen($language)), '/'); break; } } if ($uri == '') { $uri = '/'; } URI::$uri = $uri; /* |-------------------------------------------------------------------------- | Route The Incoming Request |-------------------------------------------------------------------------- | | Phew! We can finally route the request to the appropriate route and | execute the route to get the response. This will give an instance | of the Response object that we can send back to the browser | */ Request::$route = Routing\Router::route(Request::method(), $uri); $response = Request::$route->call(); /* |-------------------------------------------------------------------------- | "Render" The Response
/** * Destroy the test environment. */ public function tearDown() { $_SERVER = array(); URI::$uri = null; URI::$segments = array(); }