PHP Class eZ\Publish\Core\Repository\URLAliasService

Inheritance: implements eZ\Publish\API\Repository\URLAliasService
Show file Open project: ezsystems/ezpublish-kernel

Protected Properties

Property Type Description
$repository eZ\Publish\API\Repository\Repository
$settings array
$urlAliasHandler eZ\Publish\SPI\Persistence\Content\UrlAlias\Handler

Public Methods

Method Description
__construct ( eZ\Publish\API\Repository\Repository $repository, eZ\Publish\SPI\Persistence\Content\UrlAlias\Handler $urlAliasHandler, array $settings = [] ) Setups service with reference to repository object that created it & corresponding handler.
createGlobalUrlAlias ( string $resource, string $path, string $languageCode, boolean $forwarding = false, boolean $alwaysAvailable = false ) : eZ\Publish\API\Repository\Values\Content\URLAlias Create a user chosen $alias pointing to a resource in $languageCode.
createUrlAlias ( eZ\Publish\API\Repository\Values\Content\Location $location, string $path, string $languageCode, boolean $forwarding = false, boolean $alwaysAvailable = false ) : eZ\Publish\API\Repository\Values\Content\URLAlias Create a user chosen $alias pointing to $location in $languageCode.
listGlobalAliases ( string $languageCode = null, integer $offset, integer $limit ) : eZ\Publish\API\Repository\Values\Content\URLAlias[] List global aliases.
listLocationAliases ( eZ\Publish\API\Repository\Values\Content\Location $location, boolean $custom = true, string $languageCode = null, null | boolean $showAllTranslations = null, array $prioritizedLanguageList = null ) : eZ\Publish\API\Repository\Values\Content\URLAlias[] List of url aliases pointing to $location, sorted by language priority.
load ( string $id ) : eZ\Publish\API\Repository\Values\Content\URLAlias Loads URL alias by given $id.
lookup ( string $url, string $languageCode = null ) : eZ\Publish\API\Repository\Values\Content\URLAlias looks up the URLAlias for the given url.
removeAliases ( array $aliasList ) Removes urls aliases.
reverseLookup ( eZ\Publish\API\Repository\Values\Content\Location $location, string $languageCode = null, null | boolean $showAllTranslations = null, array $prioritizedLanguageList = null ) : eZ\Publish\API\Repository\Values\Content\URLAlias Returns the URL alias for the given location in the given language.

Protected Methods

Method Description
buildSPIUrlAlias ( eZ\Publish\API\Repository\Values\Content\URLAlias $urlAlias ) : eZ\Publish\SPI\Persistence\Content\URLAlias Builds persistence domain object.
buildUrlAliasDomainObject ( eZ\Publish\SPI\Persistence\Content\URLAlias $spiUrlAlias, string | null $path ) : eZ\Publish\API\Repository\Values\Content\URLAlias Builds API UrlAlias object from given SPI UrlAlias object.
choosePrioritizedLanguageCode ( array $entries, boolean $showAllTranslations, string[] $prioritizedLanguageList ) : string | boolean Returns language code with highest priority.
cleanUrl ( string $url ) : string
extractPath ( eZ\Publish\SPI\Persistence\Content\URLAlias $spiUrlAlias, string $languageCode, boolean $showAllTranslations, string[] $prioritizedLanguageList ) : string | boolean Returns path extracted from normalized path data returned from persistence, using language settings.
isPathLoadable ( array $pathData, array $languageCodes ) : boolean Returns true or false depending if URL alias is loadable or not for language settings in place.
isUrlAliasLoadable ( eZ\Publish\SPI\Persistence\Content\URLAlias $spiUrlAlias, string | null $languageCode, $showAllTranslations, $prioritizedLanguageList ) : boolean Returns true or false depending if URL alias is loadable or not for language settings in place.
matchLanguageCode ( array $pathElementData, string $pathElement ) : string | boolean
matchPath ( eZ\Publish\SPI\Persistence\Content\URLAlias $spiUrlAlias, string $path, string $languageCode ) : array Matches path string with normalized path data returned from persistence.
selectAliasLanguageCode ( eZ\Publish\SPI\Persistence\Content\URLAlias $spiUrlAlias, string | null $languageCode, boolean $showAllTranslations, string[] $prioritizedLanguageList ) : string | boolean Determines alias language code.

Private Methods

Method Description
sortTranslationsByPrioritizedLanguages ( array $translations ) : array Needed when translations for the part of the alias are the same for multiple languages.

Method Details

__construct() public method

Setups service with reference to repository object that created it & corresponding handler.
public __construct ( eZ\Publish\API\Repository\Repository $repository, eZ\Publish\SPI\Persistence\Content\UrlAlias\Handler $urlAliasHandler, array $settings = [] )
$repository eZ\Publish\API\Repository\Repository
$urlAliasHandler eZ\Publish\SPI\Persistence\Content\UrlAlias\Handler
$settings array

buildSPIUrlAlias() protected method

Builds persistence domain object.
protected buildSPIUrlAlias ( eZ\Publish\API\Repository\Values\Content\URLAlias $urlAlias ) : eZ\Publish\SPI\Persistence\Content\URLAlias
$urlAlias eZ\Publish\API\Repository\Values\Content\URLAlias
return eZ\Publish\SPI\Persistence\Content\URLAlias

buildUrlAliasDomainObject() protected method

Builds API UrlAlias object from given SPI UrlAlias object.
protected buildUrlAliasDomainObject ( eZ\Publish\SPI\Persistence\Content\URLAlias $spiUrlAlias, string | null $path ) : eZ\Publish\API\Repository\Values\Content\URLAlias
$spiUrlAlias eZ\Publish\SPI\Persistence\Content\URLAlias
$path string | null
return eZ\Publish\API\Repository\Values\Content\URLAlias

choosePrioritizedLanguageCode() protected method

Will return false if language code could nto be matched with language settings in place.
protected choosePrioritizedLanguageCode ( array $entries, boolean $showAllTranslations, string[] $prioritizedLanguageList ) : string | boolean
$entries array
$showAllTranslations boolean
$prioritizedLanguageList string[]
return string | boolean

cleanUrl() protected method

protected cleanUrl ( string $url ) : string
$url string
return string

createGlobalUrlAlias() public method

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.
public createGlobalUrlAlias ( string $resource, string $path, string $languageCode, boolean $forwarding = false, boolean $alwaysAvailable = false ) : eZ\Publish\API\Repository\Values\Content\URLAlias
$resource string
$path string
$languageCode string
$forwarding boolean
$alwaysAvailable boolean
return eZ\Publish\API\Repository\Values\Content\URLAlias

createUrlAlias() public method

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.
public createUrlAlias ( eZ\Publish\API\Repository\Values\Content\Location $location, string $path, string $languageCode, boolean $forwarding = false, boolean $alwaysAvailable = false ) : eZ\Publish\API\Repository\Values\Content\URLAlias
$location eZ\Publish\API\Repository\Values\Content\Location
$path string
$languageCode string the languageCode for which this alias is valid
$forwarding boolean if true a redirect is performed
$alwaysAvailable boolean
return eZ\Publish\API\Repository\Values\Content\URLAlias

extractPath() protected method

Will return false if path could not be determined.
protected extractPath ( eZ\Publish\SPI\Persistence\Content\URLAlias $spiUrlAlias, string $languageCode, boolean $showAllTranslations, string[] $prioritizedLanguageList ) : string | boolean
$spiUrlAlias eZ\Publish\SPI\Persistence\Content\URLAlias
$languageCode string
$showAllTranslations boolean
$prioritizedLanguageList string[]
return string | boolean

isPathLoadable() protected method

Returns true or false depending if URL alias is loadable or not for language settings in place.
protected isPathLoadable ( array $pathData, array $languageCodes ) : boolean
$pathData array
$languageCodes array
return boolean

isUrlAliasLoadable() protected method

Returns true or false depending if URL alias is loadable or not for language settings in place.
protected isUrlAliasLoadable ( eZ\Publish\SPI\Persistence\Content\URLAlias $spiUrlAlias, string | null $languageCode, $showAllTranslations, $prioritizedLanguageList ) : boolean
$spiUrlAlias eZ\Publish\SPI\Persistence\Content\URLAlias
$languageCode string | null
return boolean

listGlobalAliases() public method

List global aliases.
public listGlobalAliases ( string $languageCode = null, integer $offset, integer $limit ) : eZ\Publish\API\Repository\Values\Content\URLAlias[]
$languageCode string filters those which are valid for the given language
$offset integer
$limit integer
return eZ\Publish\API\Repository\Values\Content\URLAlias[]

listLocationAliases() public method

List of url aliases pointing to $location, sorted by language priority.
public listLocationAliases ( eZ\Publish\API\Repository\Values\Content\Location $location, boolean $custom = true, string $languageCode = null, null | boolean $showAllTranslations = null, array $prioritizedLanguageList = null ) : eZ\Publish\API\Repository\Values\Content\URLAlias[]
$location eZ\Publish\API\Repository\Values\Content\Location
$custom boolean if true the user generated aliases are listed otherwise the autogenerated
$languageCode string filters those which are valid for the given language
$showAllTranslations null | boolean
$prioritizedLanguageList array
return eZ\Publish\API\Repository\Values\Content\URLAlias[]

load() public method

Loads URL alias by given $id.
public load ( string $id ) : eZ\Publish\API\Repository\Values\Content\URLAlias
$id string
return eZ\Publish\API\Repository\Values\Content\URLAlias

lookup() public method

looks up the URLAlias for the given url.
public lookup ( string $url, string $languageCode = null ) : eZ\Publish\API\Repository\Values\Content\URLAlias
$url string
$languageCode string
return eZ\Publish\API\Repository\Values\Content\URLAlias

matchLanguageCode() protected method

protected matchLanguageCode ( array $pathElementData, string $pathElement ) : string | boolean
$pathElementData array
$pathElement string
return string | boolean

matchPath() protected method

Returns matched path string (possibly case corrected) and array of corresponding language codes or false if path could not be matched.
protected matchPath ( eZ\Publish\SPI\Persistence\Content\URLAlias $spiUrlAlias, string $path, string $languageCode ) : array
$spiUrlAlias eZ\Publish\SPI\Persistence\Content\URLAlias
$path string
$languageCode string
return array

removeAliases() public method

This method does not remove autogenerated aliases for locations.
public removeAliases ( array $aliasList )
$aliasList array

reverseLookup() public method

If $languageCode is null the method returns the url alias in the most prioritized language.
public reverseLookup ( eZ\Publish\API\Repository\Values\Content\Location $location, string $languageCode = null, null | boolean $showAllTranslations = null, array $prioritizedLanguageList = null ) : eZ\Publish\API\Repository\Values\Content\URLAlias
$location eZ\Publish\API\Repository\Values\Content\Location
$languageCode string
$showAllTranslations null | boolean
$prioritizedLanguageList array
return eZ\Publish\API\Repository\Values\Content\URLAlias

selectAliasLanguageCode() protected method

Method will return false if language code can't be matched against alias language codes or language settings.
protected selectAliasLanguageCode ( eZ\Publish\SPI\Persistence\Content\URLAlias $spiUrlAlias, string | null $languageCode, boolean $showAllTranslations, string[] $prioritizedLanguageList ) : string | boolean
$spiUrlAlias eZ\Publish\SPI\Persistence\Content\URLAlias
$languageCode string | null
$showAllTranslations boolean
$prioritizedLanguageList string[]
return string | boolean

Property Details

$repository protected property

protected Repository,eZ\Publish\API\Repository $repository
return eZ\Publish\API\Repository\Repository

$settings protected property

protected array $settings
return array

$urlAliasHandler protected property

protected Handler,eZ\Publish\SPI\Persistence\Content\UrlAlias $urlAliasHandler
return eZ\Publish\SPI\Persistence\Content\UrlAlias\Handler