$segments =
explode('/',
$uri);
// WARNING: Directories get shifted out of the segments array.
$segments =
$this->
scanControllers($segments);
// If we don't have any segments left - use the default controller;
// If not empty, then the first segment should be the controller
if (!
empty($segments)) { $this->controller =
ucfirst(array_shift($segments));
} $controllerName =
$this->
controllerName();
if (!
$this->
isValidSegment($controllerName)) { throw new PageNotFoundException($this->controller . ' is not a valid controller name'
);
} // Use the method name if it exists.
// If it doesn't, no biggie - the default method name
// has already been set.
if (!
empty($segments)) { $this->method =
array_shift($segments) ?:
$this->method;
}