/**
* Function to convert a route to an internal URI
*
* @param Uri &$uri The uri.
* @param bool $setVars Set the parsed data in the internal
* storage for current-request-URLs
*
* @return array
*
* @since 1.5
* @throws \Exception
*/
public function parse(&$uri, $setVars = false)
{
// Do the preprocess stage of the URL parse process
$this->processParseRules($uri, self::PROCESS_BEFORE);
// Do the main stage of the URL parse process
$this->processParseRules($uri);
// Do the postprocess stage of the URL parse process
$this->processParseRules($uri, self::PROCESS_AFTER);
// Check if all parts of the URL have been parsed.
// Otherwise we have an invalid URL
if (\strlen($uri->getPath()) > 0) {
throw new RouteNotFoundException(Text::_('JERROR_PAGE_NOT_FOUND'));
}
if ($setVars) {
$this->setVars($uri->getQuery(true));
return $this->getVars();
}
return $uri->getQuery(true);
}