public function translate($url)
{
$spiUrlWildcards = $this->urlWildcardHandler->loadAll();
// sorts wildcards by length of source URL string
// @todo sort by specificity of the pattern?
uasort($spiUrlWildcards, function (SPIUrlWildcard $w1, SPIUrlWildcard $w2) {
return strlen($w2->sourceUrl) - strlen($w1->sourceUrl);
});
foreach ($spiUrlWildcards as $wildcard) {
if ($uri = $this->match($url, $wildcard)) {
return new URLWildcardTranslationResult(array('uri' => $uri, 'forward' => $wildcard->forward));
}
}
throw new NotFoundException('URLWildcard', $url);
}