Class

eZ\Publish\Core\REST\Client\URLAliasService

class URLAliasService implements URLAliasService, Sessionable

Implementation of the {@link \eZ\Publish\API\Repository\URLAliasService} interface.

Methods

__construct(HttpClient $client, Dispatcher $inputDispatcher, Visitor $outputVisitor, RequestParser $requestParser)

setSession(mixed $id)

Set session ID.

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)

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)

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 52
public __construct(HttpClient $client, Dispatcher $inputDispatcher, Visitor $outputVisitor, RequestParser $requestParser)

Parameters

HttpClient $client
Dispatcher $inputDispatcher
Visitor $outputVisitor
RequestParser $requestParser

at line 69
public setSession(mixed $id)

Set session ID.

Only for testing

Parameters

mixed $id

at line 93
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 119
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 133
public URLAlias[] listLocationAliases(Location $location, bool $custom = true, string $languageCode = 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

Return Value

URLAlias[]

at line 147
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 162
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 177
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 194
public URLAlias reverseLookup(Location $location, string $languageCode = 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

Return Value

URLAlias

Exceptions

NotFoundException if no url alias exist for the given language

at line 208
public URLAlias load(string $id)

Loads URL alias by given $id.

Parameters

string $id

Return Value

URLAlias

Exceptions

NotFoundException