Class

eZ\Publish\Core\SignalSlot\URLAliasService

class URLAliasService implements URLAliasService

URLAliasService class.

Methods

__construct(URLAliasService $service, SignalDispatcher $signalDispatcher)

Constructor.

URLAlias createUrlAlias(Location $location, string $path, string $languageCode, bool $forwarding = false, bool $alwaysAvailable = false)

Create a user chosen $alias pointing to $location in $languageCode.

URLAlias createGlobalUrlAlias(string $resource, string $path, string $languageCode, bool $forwarding = false, bool $alwaysAvailable = false)

Create a user chosen $alias pointing to a resource in $languageCode.

URLAlias[] listLocationAliases(Location $location, bool $custom = true, string $languageCode = null, null|bool $showAllTranslations = null, array $prioritizedLanguageList = null)

List of url aliases pointing to $location, sorted by language priority.

URLAlias[] listGlobalAliases(string $languageCode = null, int $offset, int $limit = -1)

List global aliases.

removeAliases(array $aliasList)

Removes urls aliases.

URLAlias lookup(string $url, string $languageCode = null)

looks up the URLAlias for the given url.

URLAlias reverseLookup(Location $location, string $languageCode = null, null|bool $showAllTranslations = null, array $prioritizedLanguageList = null)

Returns the URL alias for the given location in the given language.

URLAlias load(string $id)

Loads URL alias by given $id.

Details

at line 45
public __construct(URLAliasService $service, SignalDispatcher $signalDispatcher)

Constructor.

Construct service object from aggregated service and signal dispatcher

Parameters

URLAliasService $service
SignalDispatcher $signalDispatcher

at line 68
public URLAlias createUrlAlias(Location $location, string $path, string $languageCode, bool $forwarding = false, bool $alwaysAvailable = false)

Create a user chosen $alias pointing to $location in $languageCode.

This method runs URL filters and transformers before storing them. Hence the path returned in the URLAlias Value may differ from the given. $alwaysAvailable makes the alias available in all languages.

Parameters

Location $location
string $path
string $languageCode the languageCode for which this alias is valid
bool $forwarding if true a redirect is performed
bool $alwaysAvailable

Return Value

URLAlias

Exceptions

InvalidArgumentException if the path already exists for the given language

at line 103
public URLAlias createGlobalUrlAlias(string $resource, string $path, string $languageCode, bool $forwarding = false, bool $alwaysAvailable = false)

Create a user chosen $alias pointing to a resource in $languageCode.

This method does not handle location resources - if a user enters a location target the createCustomUrlAlias method has to be used. This method runs URL filters and and transformers before storing them. Hence the path returned in the URLAlias Value may differ from the given.

$alwaysAvailable makes the alias available in all languages.

Parameters

string $resource
string $path
string $languageCode
bool $forwarding
bool $alwaysAvailable

Return Value

URLAlias

Exceptions

InvalidArgumentException if the path already exists for the given language or if resource is not valid

at line 128
public URLAlias[] listLocationAliases(Location $location, bool $custom = true, string $languageCode = null, null|bool $showAllTranslations = null, array $prioritizedLanguageList = null)

List of url aliases pointing to $location, sorted by language priority.

Parameters

Location $location
bool $custom if true the user generated aliases are listed otherwise the autogenerated
string $languageCode filters those which are valid for the given language
null|bool $showAllTranslations
array $prioritizedLanguageList

Return Value

URLAlias[]

at line 153
public URLAlias[] listGlobalAliases(string $languageCode = null, int $offset, int $limit = -1)

List global aliases.

Parameters

string $languageCode filters those which are valid for the given language
int $offset
int $limit

Return Value

URLAlias[]

at line 168
public removeAliases(array $aliasList)

Removes urls aliases.

This method does not remove autogenerated aliases for locations.

Parameters

array $aliasList

Exceptions

InvalidArgumentException if alias list contains autogenerated alias

at line 192
public URLAlias lookup(string $url, string $languageCode = null)

looks up the URLAlias for the given url.

Parameters

string $url
string $languageCode

Return Value

URLAlias

Exceptions

NotFoundException if the path does not exist or is not valid for the given language

at line 211
public URLAlias reverseLookup(Location $location, string $languageCode = null, null|bool $showAllTranslations = null, array $prioritizedLanguageList = null)

Returns the URL alias for the given location in the given language.

If $languageCode is null the method returns the url alias in the most prioritized language.

Parameters

Location $location
string $languageCode
null|bool $showAllTranslations
array $prioritizedLanguageList

Return Value

URLAlias

Exceptions

NotFoundException if no url alias exist for the given language

at line 234
public URLAlias load(string $id)

Loads URL alias by given $id.

Parameters

string $id

Return Value

URLAlias

Exceptions

NotFoundException