<? class router { private $route; private $controller; private $action; private $params; public function __construct() { { require_once("app/config/routes.php"); } $config = loader::load("config"); { $default_controller = $config->default_controller; $path[0] = $default_controller; else $path[0] = "index"; } $route= $path[0]; $sanitzing_pattern = $config->allowed_url_chars; $this->route = $route; $this->controller=$routeParts[0]; $this->params=$routeParts; /* Dopasowanie wzorca routingu zdefiniowanego przez użytkownika. */ foreach ($routes as $_route) { $_pattern = "~{$_route[0]}~"; $_destination = $_route[1]; { $this->controller = $newrouteparts[0]; $this->action = $newrouteparts[1]; } } } } public function getAction() { return $this->action; } public function getController() { return $this->controller; } public function getParams() { return $this->params; } } ?>
W jaki sposób obiekt routera pobiera w tym przypadku adres URL do obróbki i czy dyrektywa array_shift jest w dobrym miejscu?