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

Its methods operate on a representation of the url alias data structure held inside a storage engine.
Inheritance: implements eZ\Publish\SPI\Persistence\Content\UrlAlias\Handler
Show file Open project: ezsystems/ezpublish-kernel Class Usage Examples

Protected Properties

Property Type Description
$gateway Gateway UrlAlias Gateway.
$languageHandler eZ\Publish\Core\Persistence\Legacy\Content\Language\CachingHandler Caching language handler.
$locationGateway eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway Gateway for handling location data.
$mapper Mapper UrlAlias Mapper.
$slugConverter SlugConverter URL slug converter.

Public Methods

Method Description
__construct ( Gateway $gateway, Mapper $mapper, Gateway $locationGateway, eZ\Publish\SPI\Persistence\Content\Language\Handler $languageHandler, SlugConverter $slugConverter ) Creates a new UrlAlias Handler.
createCustomUrlAlias ( mixed $locationId, string $path, boolean $forwarding = false, string $languageCode = null, boolean $alwaysAvailable = false ) : eZ\Publish\SPI\Persistence\Content\UrlAlias Create a user chosen $alias pointing to $locationId in $languageCode.
createGlobalUrlAlias ( string $resource, string $path, boolean $forwarding = false, string $languageCode = null, boolean $alwaysAvailable = false ) : eZ\Publish\SPI\Persistence\Content\UrlAlias Create a user chosen $alias pointing to a resource in $languageCode.
listGlobalURLAliases ( string | null $languageCode = null, integer $offset, integer $limit ) : eZ\Publish\SPI\Persistence\Content\UrlAlias[] List global aliases.
listURLAliasesForLocation ( mixed $locationId, boolean $custom = false ) : eZ\Publish\SPI\Persistence\Content\UrlAlias[] List of user generated or autogenerated url entries, pointing to $locationId.
loadUrlAlias ( string $id ) : eZ\Publish\SPI\Persistence\Content\UrlAlias Loads URL alias by given $id.
locationCopied ( mixed $locationId, mixed $newLocationId, mixed $newParentId ) Notifies the underlying engine that a location was copied.
locationDeleted ( mixed $locationId ) Notifies the underlying engine that a location was deleted or moved to trash.
locationMoved ( mixed $locationId, mixed $oldParentId, mixed $newParentId ) Notifies the underlying engine that a location has moved.
locationSwapped ( $location1Id, $location1ParentId, $location2Id, $location2ParentId )
lookup ( string $url ) : eZ\Publish\SPI\Persistence\Content\UrlAlias Looks up a url alias for the given url.
publishUrlAliasForLocation ( $locationId, $parentLocationId, $name, $languageCode, $alwaysAvailable = false, $updatePathIdentificationString = false )
removeURLAliases ( array $urlAliases ) : boolean Removes url aliases.

Protected Methods

Method Description
copySubtree ( array $actionMap, mixed $oldParentAliasId, mixed $newParentAliasId ) Recursively copies aliases from old parent under new parent.
createUrlAlias ( string $action, string $path, boolean $forward, string | null $languageCode, boolean $alwaysAvailable ) : eZ\Publish\SPI\Persistence\Content\UrlAlias Internal method for creating global or custom URL alias (these are handled in the same way).
getCopiedLocationsMap ( mixed $oldParentId, mixed $newParentId ) : array
getHash ( string $text ) : string
getRealAliasId ( mixed $locationId ) : mixed Returns possibly corrected alias id for given $locationId !! For use as parent id in logic.
insertNopEntry ( mixed $parentId, string $text, string $textMD5 ) : mixed Convenience method for inserting nop type row.
removeSubtree ( mixed $id, string $action, mixed $original ) Recursively removes aliases by given $id and $action.

Private Methods

Method Description
extractLanguageIdsFromMask ( integer $languageMask ) : int[] Extracts every language Ids contained in $languageMask.
historizeBeforeSwap ( array $location1Entries, array $location2Entries ) Historizes given existing active entries for two swapped Locations.
internalPublishUrlAliasForLocation ( integer $locationId, integer $parentLocationId, string $name, integer $languageId, boolean $alwaysAvailable = false, boolean $updatePathIdentificationString = false, integer $newId = null ) Internal publish method, accepting language ID instead of language code and optionally new alias ID (used when swapping Locations).

Method Details

__construct() public method

Creates a new UrlAlias Handler.
public __construct ( Gateway $gateway, Mapper $mapper, Gateway $locationGateway, eZ\Publish\SPI\Persistence\Content\Language\Handler $languageHandler, SlugConverter $slugConverter )
$gateway Gateway
$mapper Mapper
$locationGateway eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway
$languageHandler eZ\Publish\SPI\Persistence\Content\Language\Handler
$slugConverter SlugConverter

copySubtree() protected method

Recursively copies aliases from old parent under new parent.
protected copySubtree ( array $actionMap, mixed $oldParentAliasId, mixed $newParentAliasId )
$actionMap array
$oldParentAliasId mixed
$newParentAliasId mixed

createCustomUrlAlias() public method

If $languageCode is null the $alias is created in the system's default language. $alwaysAvailable makes the alias available in all languages.
public createCustomUrlAlias ( mixed $locationId, string $path, boolean $forwarding = false, string $languageCode = null, boolean $alwaysAvailable = false ) : eZ\Publish\SPI\Persistence\Content\UrlAlias
$locationId mixed
$path string
$forwarding boolean
$languageCode string
$alwaysAvailable boolean
return eZ\Publish\SPI\Persistence\Content\UrlAlias

createGlobalUrlAlias() public method

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.
public createGlobalUrlAlias ( string $resource, string $path, boolean $forwarding = false, string $languageCode = null, boolean $alwaysAvailable = false ) : eZ\Publish\SPI\Persistence\Content\UrlAlias
$resource string
$path string
$forwarding boolean
$languageCode string
$alwaysAvailable boolean
return eZ\Publish\SPI\Persistence\Content\UrlAlias

createUrlAlias() protected method

Internal method for creating global or custom URL alias (these are handled in the same way).
protected createUrlAlias ( string $action, string $path, boolean $forward, string | null $languageCode, boolean $alwaysAvailable ) : eZ\Publish\SPI\Persistence\Content\UrlAlias
$action string
$path string
$forward boolean
$languageCode string | null
$alwaysAvailable boolean
return eZ\Publish\SPI\Persistence\Content\UrlAlias

getCopiedLocationsMap() protected method

protected getCopiedLocationsMap ( mixed $oldParentId, mixed $newParentId ) : array
$oldParentId mixed
$newParentId mixed
return array

getHash() protected method

protected getHash ( string $text ) : string
$text string
return string

getRealAliasId() protected method

First level entries must have parent id set to 0 instead of their parent location alias id. There are two cases when alias id needs to be corrected: 1) location is special location without URL alias (location with id=1 in standard installation) 2) location is site root location, having special root entry in the ezurlalias_ml table (location with id=2 in standard installation)
protected getRealAliasId ( mixed $locationId ) : mixed
$locationId mixed
return mixed

insertNopEntry() protected method

Convenience method for inserting nop type row.
protected insertNopEntry ( mixed $parentId, string $text, string $textMD5 ) : mixed
$parentId mixed
$text string
$textMD5 string
return mixed

listGlobalURLAliases() public method

List global aliases.
public listGlobalURLAliases ( string | null $languageCode = null, integer $offset, integer $limit ) : eZ\Publish\SPI\Persistence\Content\UrlAlias[]
$languageCode string | null
$offset integer
$limit integer
return eZ\Publish\SPI\Persistence\Content\UrlAlias[]

listURLAliasesForLocation() public method

List of user generated or autogenerated url entries, pointing to $locationId.
public listURLAliasesForLocation ( mixed $locationId, boolean $custom = false ) : eZ\Publish\SPI\Persistence\Content\UrlAlias[]
$locationId mixed
$custom boolean if true the user generated aliases are listed otherwise the autogenerated
return eZ\Publish\SPI\Persistence\Content\UrlAlias[]

loadUrlAlias() public method

Loads URL alias by given $id.
public loadUrlAlias ( string $id ) : eZ\Publish\SPI\Persistence\Content\UrlAlias
$id string
return eZ\Publish\SPI\Persistence\Content\UrlAlias

locationCopied() public method

This method triggers the creation of the autogenerated aliases for the copied locations
public locationCopied ( mixed $locationId, mixed $newLocationId, mixed $newParentId )
$locationId mixed
$newLocationId mixed
$newParentId mixed

locationDeleted() public method

Notifies the underlying engine that a location was deleted or moved to trash.
public locationDeleted ( mixed $locationId )
$locationId mixed

locationMoved() public method

This method triggers the change of the autogenerated aliases.
public locationMoved ( mixed $locationId, mixed $oldParentId, mixed $newParentId )
$locationId mixed
$oldParentId mixed
$newParentId mixed

locationSwapped() public method

public locationSwapped ( $location1Id, $location1ParentId, $location2Id, $location2ParentId )

lookup() public method

Looks up a url alias for the given url.
public lookup ( string $url ) : eZ\Publish\SPI\Persistence\Content\UrlAlias
$url string
return eZ\Publish\SPI\Persistence\Content\UrlAlias

publishUrlAliasForLocation() public method

public publishUrlAliasForLocation ( $locationId, $parentLocationId, $name, $languageCode, $alwaysAvailable = false, $updatePathIdentificationString = false )

removeSubtree() protected method

$original parameter is used to limit removal of moved Location aliases to history entries only.
protected removeSubtree ( mixed $id, string $action, mixed $original )
$id mixed
$action string
$original mixed

removeURLAliases() public method

Autogenerated aliases are not removed by this method.
public removeURLAliases ( array $urlAliases ) : boolean
$urlAliases array
return boolean

Property Details

$gateway protected property

UrlAlias Gateway.
protected Gateway,eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias $gateway
return Gateway

$languageHandler protected property

Caching language handler.
protected CachingHandler,eZ\Publish\Core\Persistence\Legacy\Content\Language $languageHandler
return eZ\Publish\Core\Persistence\Legacy\Content\Language\CachingHandler

$locationGateway protected property

Gateway for handling location data.
protected Gateway,eZ\Publish\Core\Persistence\Legacy\Content\Location $locationGateway
return eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway

$mapper protected property

UrlAlias Mapper.
protected Mapper,eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias $mapper
return Mapper

$slugConverter protected property

URL slug converter.
protected SlugConverter,eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias $slugConverter
return SlugConverter