eZ\Publish\Core\Repository\URLAliasService::reverseLookup PHP Method

reverseLookup() public method

If $languageCode is null the method returns the url alias in the most prioritized language.
public reverseLookup ( eZ\Publish\API\Repository\Values\Content\Location $location, string $languageCode = null, null | boolean $showAllTranslations = null, array $prioritizedLanguageList = null ) : eZ\Publish\API\Repository\Values\Content\URLAlias
$location eZ\Publish\API\Repository\Values\Content\Location
$languageCode string
$showAllTranslations null | boolean
$prioritizedLanguageList array
return eZ\Publish\API\Repository\Values\Content\URLAlias
    public function reverseLookup(Location $location, $languageCode = null, $showAllTranslations = null, array $prioritizedLanguageList = null)
    {
        if ($showAllTranslations === null) {
            $showAllTranslations = $this->settings['showAllTranslations'];
        }
        if ($prioritizedLanguageList === null) {
            $prioritizedLanguageList = $this->settings['prioritizedLanguageList'];
        }
        $urlAliases = $this->listLocationAliases($location, false, $languageCode, $showAllTranslations, $prioritizedLanguageList);
        foreach ($prioritizedLanguageList as $prioritizedLanguageCode) {
            foreach ($urlAliases as $urlAlias) {
                if (in_array($prioritizedLanguageCode, $urlAlias->languageCodes)) {
                    return $urlAlias;
                }
            }
        }
        foreach ($urlAliases as $urlAlias) {
            if ($urlAlias->alwaysAvailable) {
                return $urlAlias;
            }
        }
        if (!empty($urlAliases) && $showAllTranslations) {
            return reset($urlAliases);
        }
        throw new NotFoundException('URLAlias', $location->id);
    }