Class

eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler

class Handler implements Handler

The UrlAlias Handler provides nice urls management.

Its methods operate on a representation of the url alias data structure held inside a storage engine.

Constants

ROOT_LOCATION_ID

CONTENT_REPOSITORY_ROOT_LOCATION_ID

This is intentionally hardcoded for now as: 1.

We don't implement this configuration option. 2. Such option should not be in this layer, should be handled higher up.

MAX_URL_ALIAS_DEPTH_LEVEL

The maximum level of alias depth.

Methods

__construct(Gateway $gateway, Mapper $mapper, Gateway $locationGateway, Handler $languageHandler, SlugConverter $slugConverter)

Creates a new UrlAlias Handler.

publishUrlAliasForLocation(mixed $locationId, mixed $parentLocationId, string $name, string $languageCode, bool $alwaysAvailable = false, $updatePathIdentificationString = false)

This method creates or updates an urlalias from a new or changed content name in a language (if published).

UrlAlias createCustomUrlAlias(mixed $locationId, string $path, bool $forwarding = false, string $languageCode = null, bool $alwaysAvailable = false)

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

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

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

UrlAlias[] listURLAliasesForLocation(mixed $locationId, bool $custom = false)

List of user generated or autogenerated url entries, pointing to $locationId.

UrlAlias[] listGlobalURLAliases(string|null $languageCode = null, int $offset, int $limit = -1)

List global aliases.

bool removeURLAliases(array $urlAliases)

Removes url aliases.

UrlAlias lookup(string $url)

Looks up a url alias for the given url.

UrlAlias loadUrlAlias(string $id)

Loads URL alias by given $id.

locationMoved(mixed $locationId, mixed $oldParentId, mixed $newParentId)

Notifies the underlying engine that a location has moved.

locationCopied(mixed $locationId, mixed $newLocationId, mixed $newParentId)

Notifies the underlying engine that a location was copied.

locationSwapped(string|int $location1Id, string|int $location1ParentId, string|int $location2Id, string|int $location2ParentId)

Notifies the underlying engine that a location was swapped.

locationDeleted(mixed $locationId)

Notifies the underlying engine that a location was deleted or moved to trash.

translationRemoved(array $locationIds, string $languageCode)

Notifies the underlying engine that Locations Content Translation was removed.

archiveUrlAliasesForDeletedTranslations(int $locationId, int $parentLocationId, array $languageCodes)

Archive UrlAliases for Translations that were removed from the underlying published content.

Details

at line 88
public __construct(Gateway $gateway, Mapper $mapper, Gateway $locationGateway, Handler $languageHandler, SlugConverter $slugConverter)

Creates a new UrlAlias Handler.

Parameters

Gateway $gateway
Mapper $mapper
Gateway $locationGateway
Handler $languageHandler
SlugConverter $slugConverter

at line 102
public publishUrlAliasForLocation(mixed $locationId, mixed $parentLocationId, string $name, string $languageCode, bool $alwaysAvailable = false, $updatePathIdentificationString = false)

This method creates or updates an urlalias from a new or changed content name in a language (if published).

It also can be used to create an alias for a new location of content. On update the old alias is linked to the new one (i.e. a history alias is generated).

$alwaysAvailable controls whether the url alias is accessible in all languages.

Parameters

mixed $locationId
mixed $parentLocationId
string $name the new name computed by the name schema or url alias schema
string $languageCode
bool $alwaysAvailable
$updatePathIdentificationString

at line 284
public UrlAlias createCustomUrlAlias(mixed $locationId, string $path, bool $forwarding = false, string $languageCode = null, bool $alwaysAvailable = false)

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

If $languageCode is null the $alias is created in the system's default language. $alwaysAvailable makes the alias available in all languages.

Parameters

mixed $locationId
string $path
bool $forwarding
string $languageCode
bool $alwaysAvailable

Return Value

UrlAlias

at line 313
public UrlAlias createGlobalUrlAlias(string $resource, string $path, bool $forwarding = false, string $languageCode = null, 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.

If $languageCode is null the $alias is created in the system's default language. $alwaysAvailable makes the alias available in all languages.

Parameters

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

Return Value

UrlAlias

Exceptions

ForbiddenException if the path already exists for the given language

at line 443
public UrlAlias[] listURLAliasesForLocation(mixed $locationId, bool $custom = false)

List of user generated or autogenerated url entries, pointing to $locationId.

Parameters

mixed $locationId
bool $custom if true the user generated aliases are listed otherwise the autogenerated

Return Value

UrlAlias[]

at line 462
public UrlAlias[] listGlobalURLAliases(string|null $languageCode = null, int $offset, int $limit = -1)

List global aliases.

Parameters

string|null $languageCode
int $offset
int $limit

Return Value

UrlAlias[]

at line 481
public bool removeURLAliases(array $urlAliases)

Removes url aliases.

Autogenerated aliases are not removed by this method.

Parameters

array $urlAliases

Return Value

bool

at line 507
public UrlAlias lookup(string $url)

Looks up a url alias for the given url.

at line 553
public UrlAlias loadUrlAlias(string $id)

Loads URL alias by given $id.

Parameters

string $id

Return Value

UrlAlias

Exceptions

NotFoundException

at line 576
public locationMoved(mixed $locationId, mixed $oldParentId, mixed $newParentId)

Notifies the underlying engine that a location has moved.

This method triggers the change of the autogenerated aliases.

Parameters

mixed $locationId
mixed $oldParentId
mixed $newParentId

at line 606
public locationCopied(mixed $locationId, mixed $newLocationId, mixed $newParentId)

Notifies the underlying engine that a location was copied.

This method triggers the creation of the autogenerated aliases for the copied locations

Parameters

mixed $locationId
mixed $newLocationId
mixed $newParentId

at line 620
public locationSwapped(string|int $location1Id, string|int $location1ParentId, string|int $location2Id, string|int $location2ParentId)

Notifies the underlying engine that a location was swapped.

This method triggers the change of the autogenerated aliases.

Parameters

string|int $location1Id
string|int $location1ParentId
string|int $location2Id
string|int $location2ParentId

at line 809
public locationDeleted(mixed $locationId)

Notifies the underlying engine that a location was deleted or moved to trash.

Parameters

mixed $locationId

at line 823
public translationRemoved(array $locationIds, string $languageCode)

Notifies the underlying engine that Locations Content Translation was removed.

Parameters

array $locationIds all Locations of the Content that got Translation removed
string $languageCode language code of the removed Translation

at line 877
public archiveUrlAliasesForDeletedTranslations(int $locationId, int $parentLocationId, array $languageCodes)

Archive UrlAliases for Translations that were removed from the underlying published content.

Parameters

int $locationId Location of underlying published Content Object
int $parentLocationId
array $languageCodes Language codes of currently published Content Object Translations