Copied!

URLAliasService

URLAliasService.php : 17

URLAlias service.

Methods

publiccreateGlobalUrlAlias()

URLAliasService.php : 68

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

public createGlobalUrlAlias(string $resource, string $path, string $languageCode[, bool $forwarding = false ][, bool $alwaysAvailable = false ]) : URLAlias

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

Name Type Default value Description
$resource string - -
$path string - -
$languageCode string - -
$forwarding bool false -
$alwaysAvailable bool false -

Return values

URLAlias

Tags
Throws
UnauthorizedException

if the user is not allowed to create global url alias

Throws
InvalidArgumentException

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

publiccreateUrlAlias()

URLAliasService.php : 37

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

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

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

Name Type Default value Description
$location Location - -
$path string - -
$languageCode string -

the languageCode for which this alias is valid

$forwarding bool false

if true a redirect is performed

$alwaysAvailable bool false -

Return values

URLAlias

Tags
Throws
UnauthorizedException

if the user is not allowed to create url alias

Throws
InvalidArgumentException

if the path already exists for the given context

publicdeleteCorruptedUrlAliases()

URLAliasService.php : 176

Delete global, system or custom URL alias pointing to non-existent Locations.

public deleteCorruptedUrlAliases() : int

Return values

int

Number of deleted URL aliases

publiclistGlobalAliases()

URLAliasService.php : 104

List global aliases.

public listGlobalAliases([string|null $languageCode = null ][, int $offset = 0 ][, int $limit = -1 ]) : array<string|int, URLAlias>

Parameters

Name Type Default value Description
$languageCode string|null null

filters those which are valid for the given language

$offset int 0 -
$limit int -1 -

Return values

array<string|int, URLAlias>

publiclistLocationAliases()

URLAliasService.php : 87

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

public listLocationAliases(Location $location[, bool $custom = true ][, string|null $languageCode = null ][, bool|null $showAllTranslations = null ][, array<string|int, string>|null $prioritizedLanguages = null ]) : array<string|int, URLAlias>

Parameters

Name Type Default value Description
$location Location - -
$custom bool true

if true the user generated aliases are listed otherwise the autogenerated

$languageCode string|null null

filters those which are valid for the given language

$showAllTranslations bool|null null

If enabled will include all alias as if they where always available.

$prioritizedLanguages array<string|int, string>|null null

If set used as prioritized language codes, returning first match.

Return values

array<string|int, URLAlias>

publicload()

URLAliasService.php : 162

Loads URL alias by given $id.

public load(string $id) : URLAlias

Parameters

Name Type Default value Description
$id string - -

Return values

URLAlias

Tags
Throws
NotFoundException

publiclookup()

URLAliasService.php : 130

looks up the URLAlias for the given url.

public lookup(string $url[, string|null $languageCode = null ]) : URLAlias

Parameters

Name Type Default value Description
$url string - -
$languageCode string|null null -

Return values

URLAlias

Tags
Throws
NotFoundException

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

Throws
InvalidArgumentException

if the path exceeded maximum depth level

publicrefreshSystemUrlAliasesForLocation()

URLAliasService.php : 169

Refresh all system URL aliases for the given Location (and historize outdated if needed).

public refreshSystemUrlAliasesForLocation(Location $location) : void

Parameters

Name Type Default value Description
$location Location - -

publicremoveAliases()

URLAliasService.php : 117

Removes urls aliases.

public removeAliases(array<string|int, URLAlias$aliasList) : void

This method does not remove autogenerated aliases for locations.

Parameters

Name Type Default value Description
$aliasList array<string|int, URLAlias> - -
Tags
Throws
UnauthorizedException

if the user is not allowed to remove url alias

Throws
InvalidArgumentException

if alias list contains autogenerated alias

publicreverseLookup()

URLAliasService.php : 146

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

public reverseLookup(Location $location[, string|null $languageCode = null ][, bool|null $showAllTranslations = null ][, array<string|int, string>|null $prioritizedLanguages = null ]) : URLAlias

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

Parameters

Name Type Default value Description
$location Location - -
$languageCode string|null null

filters those which are valid for the given language

$showAllTranslations bool|null null

If enabled will include all alias as if they where always available.

$prioritizedLanguages array<string|int, string>|null null

If set used as prioritized language codes, returning first match.

Return values

URLAlias

Tags
Throws
NotFoundException

if no url alias exist for the given language