Exponential 5.x Kernel 7.5.40 Exponential New Stack (Symfony-based) Kernel — PHP Class Reference

Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
eZ\Publish\Core\Repository\URLAliasService Class Reference
Inheritance diagram for eZ\Publish\Core\Repository\URLAliasService:

## Public Member Functions
| __construct (RepositoryInterface $repository, Handler $urlAliasHandler, Helper\NameSchemaService $nameSchemaService, PermissionResolver $permissionResolver, array $settings=[])
| Setups service with reference to repository object that created it & corresponding handler. More...
| createUrlAlias (Location $location, $path, $languageCode, $forwarding=false, $alwaysAvailable=false)
| Create a user chosen $alias pointing to $location in $languageCode. More...
| createGlobalUrlAlias ($resource, $path, $languageCode, $forwarding=false, $alwaysAvailable=false)
| Create a user chosen $alias pointing to a resource in $languageCode. More...
| listLocationAliases (Location $location, $custom=true, $languageCode=null, $showAllTranslations=null, array $prioritizedLanguageList=null)
| List of url aliases pointing to $location, sorted by language priority. More...
| listGlobalAliases ($languageCode=null, $offset=0, $limit=-1)
| List global aliases. More...
| removeAliases (array $aliasList)
| Removes urls aliases. More...
| lookup ($url, $languageCode=null)
| looks up the URLAlias for the given url. More...
| reverseLookup (Location $location, $languageCode=null, bool $showAllTranslations=null, array $prioritizedLanguageList=null)
| Returns the URL alias for the given location in the given language. More...
| load ($id)
| Loads URL alias by given $id. More...
| refreshSystemUrlAliasesForLocation (Location $location)
| Refresh all system URL aliases for the given Location (and historize outdated if needed). More...
| deleteCorruptedUrlAliases ()
| Delete global, system or custom URL alias pointing to non-existent Locations. More...
Public Member Functions inherited from eZ\Publish\API\Repository\URLAliasService
| listLocationAliases (Location $location, $custom=true, $languageCode=null)
| List of url aliases pointing to $location, sorted by language priority. More...
| reverseLookup (Location $location, $languageCode=null)
| Returns the URL alias for the given location in the given language. More...

## Protected Member Functions
| selectAliasLanguageCode (SPIURLAlias $spiUrlAlias, ?string $languageCode, bool $showAllTranslations, array $prioritizedLanguageList)
| Determines alias language code. More...
| extractPath (SPIURLAlias $spiUrlAlias, $languageCode, $showAllTranslations, array $prioritizedLanguageList)
| Returns path extracted from normalized path data returned from persistence, using language settings. More...
| choosePrioritizedLanguageCode (array $entries, $showAllTranslations, array $prioritizedLanguageList)
| Returns language code with highest priority. More...
| matchPath (SPIURLAlias $spiUrlAlias, $path, $languageCode)
| Matches path string with normalized path data returned from persistence. More...
| matchLanguageCode (array $pathElementData, $pathElement)
| isUrlAliasLoadable (SPIURLAlias $spiUrlAlias, ?string $languageCode, bool $showAllTranslations, array $prioritizedLanguageList)
| Returns true or false depending if URL alias is loadable or not for language settings in place. More...
| isPathLoadable (array $pathData, array $languageCodes)
| Returns true or false depending if URL alias is loadable or not for language settings in place. More...
| buildSPIUrlAlias (URLAlias $urlAlias)
| Builds persistence domain object. More...
| cleanUrl (string $url)
| buildUrlAliasDomainObject (SPIURLAlias $spiUrlAlias, string $path)
| Builds API UrlAlias object from given SPI UrlAlias object. More...

## Protected Attributes
| $repository
| $urlAliasHandler
| $settings
| $nameSchemaService

## Private Member Functions
| sortTranslationsByPrioritizedLanguages (array $translations)
| Needed when translations for the part of the alias are the same for multiple languages. More...

## Private Attributes
| $permissionResolver

## Detailed Description

Definition at line 27 of file Core/Repository/URLAliasService.php.

## Constructor & Destructor Documentation

## ◆ __construct()

eZ\Publish\Core\Repository\URLAliasService::__construct | ( | RepositoryInterface | $repository,
|  | Handler | $urlAliasHandler,
|  | Helper\NameSchemaService | $nameSchemaService,
|  | PermissionResolver | $permissionResolver,
|  | array | $settings = `[]`
| ) |  |

Setups service with reference to repository object that created it & corresponding handler.

Parameters

  \eZ\Publish\API\Repository\Repository | $repository |
  \eZ\Publish\SPI\Persistence\Content\UrlAlias\Handler | $urlAliasHandler |

Definition at line 53 of file Core/Repository/URLAliasService.php.

References eZ\Publish\Core\Repository\URLAliasService\$nameSchemaService, eZ\Publish\Core\Repository\URLAliasService\$permissionResolver, eZ\Publish\Core\Repository\URLAliasService\$repository, eZ\Publish\Core\Repository\URLAliasService\$settings, and eZ\Publish\Core\Repository\URLAliasService\$urlAliasHandler.

## Member Function Documentation

## ◆ buildSPIUrlAlias()

eZ\Publish\Core\Repository\URLAliasService::buildSPIUrlAlias | ( | URLAlias | $urlAlias | ) |
| protected

Builds persistence domain object.

Parameters

  \eZ\Publish\API\Repository\Values\Content\URLAlias | $urlAlias |

Returns
  \eZ\Publish\SPI\Persistence\Content\URLAlias

Definition at line 629 of file Core/Repository/URLAliasService.php.

Referenced by eZ\Publish\Core\Repository\URLAliasService\removeAliases().

## ◆ buildUrlAliasDomainObject()

eZ\Publish\Core\Repository\URLAliasService::buildUrlAliasDomainObject | ( | SPIURLAlias | $spiUrlAlias,
|  | string | $path
| ) |  |
| protected

Builds API UrlAlias object from given SPI UrlAlias object.

Parameters

  \eZ\Publish\SPI\Persistence\Content\URLAlias | $spiUrlAlias |
  string | $path |

Returns
  \eZ\Publish\API\Repository\Values\Content\URLAlias

Definition at line 826 of file Core/Repository/URLAliasService.php.

Referenced by eZ\Publish\Core\Repository\URLAliasService\createGlobalUrlAlias(), eZ\Publish\Core\Repository\URLAliasService\createUrlAlias(), eZ\Publish\Core\Repository\URLAliasService\listGlobalAliases(), eZ\Publish\Core\Repository\URLAliasService\listLocationAliases(), eZ\Publish\Core\Repository\URLAliasService\load(), and eZ\Publish\Core\Repository\URLAliasService\lookup().

## ◆ choosePrioritizedLanguageCode()

eZ\Publish\Core\Repository\URLAliasService::choosePrioritizedLanguageCode | ( | array | $entries,
|  |  | $showAllTranslations,
|  | array | $prioritizedLanguageList
| ) |  |
| protected

Returns language code with highest priority.

Will return false if language code could not be matched with language settings in place.

Parameters

  array | $entries |
  bool | $showAllTranslations |
  string[] | $prioritizedLanguageList |

Returns
  string|bool

Definition at line 371 of file Core/Repository/URLAliasService.php.

Referenced by eZ\Publish\Core\Repository\URLAliasService\extractPath().

## ◆ cleanUrl()

eZ\Publish\Core\Repository\URLAliasService::cleanUrl | ( | string | $url | ) |
| protected

Parameters

  string | $url |

Returns
  string

Definition at line 813 of file Core/Repository/URLAliasService.php.

Referenced by eZ\Publish\Core\Repository\URLAliasService\createGlobalUrlAlias(), eZ\Publish\Core\Repository\URLAliasService\createUrlAlias(), and eZ\Publish\Core\Repository\URLAliasService\lookup().

## ◆ createGlobalUrlAlias()

eZ\Publish\Core\Repository\URLAliasService::createGlobalUrlAlias | ( |  | $resource,
|  |  | $path,
|  |  | $languageCode,
|  |  | $forwarding = `false`,
|  |  | $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.

Exceptions

Implements eZ\Publish\API\Repository\URLAliasService.

Definition at line 147 of file Core/Repository/URLAliasService.php.

References eZ\Publish\Core\Repository\URLAliasService\buildUrlAliasDomainObject(), eZ\Publish\Core\Repository\URLAliasService\cleanUrl(), and eZ\Publish\Core\Repository\URLAliasService\createUrlAlias().

## ◆ createUrlAlias()

eZ\Publish\Core\Repository\URLAliasService::createUrlAlias | ( | Location | $location,
|  |  | $path,
|  |  | $languageCode,
|  |  | $forwarding = `false`,
|  |  | $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

  \eZ\Publish\API\Repository\Values\Content\Location | $location |
  string | $path |
  bool | $forwarding | if true a redirect is performed
  string | $languageCode | the languageCode for which this alias is valid
  bool | $alwaysAvailable |

Exceptions

Implements eZ\Publish\API\Repository\URLAliasService.

Definition at line 91 of file Core/Repository/URLAliasService.php.

References eZ\Publish\Core\Repository\URLAliasService\buildUrlAliasDomainObject(), and eZ\Publish\Core\Repository\URLAliasService\cleanUrl().

Referenced by eZ\Publish\Core\Repository\URLAliasService\createGlobalUrlAlias().

## ◆ deleteCorruptedUrlAliases()

eZ\Publish\Core\Repository\URLAliasService::deleteCorruptedUrlAliases | ( |  | ) |

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

Returns
  int Number of removed URL aliases

Exceptions

Implements eZ\Publish\API\Repository\URLAliasService.

Definition at line 799 of file Core/Repository/URLAliasService.php.

## ◆ extractPath()

eZ\Publish\Core\Repository\URLAliasService::extractPath | ( | SPIURLAlias | $spiUrlAlias,
|  |  | $languageCode,
|  |  | $showAllTranslations,
|  | array | $prioritizedLanguageList
| ) |  |
| protected

Returns path extracted from normalized path data returned from persistence, using language settings.

Will return false if path could not be determined.

Parameters

  \eZ\Publish\SPI\Persistence\Content\URLAlias | $spiUrlAlias |
  string | $languageCode |
  bool | $showAllTranslations |
  string[] | $prioritizedLanguageList |

Returns
  string|bool

Definition at line 325 of file Core/Repository/URLAliasService.php.

References eZ\Publish\Core\Repository\URLAliasService\choosePrioritizedLanguageCode(), and eZ\Publish\Core\Repository\URLAliasService\selectAliasLanguageCode().

Referenced by eZ\Publish\Core\Repository\URLAliasService\listGlobalAliases(), eZ\Publish\Core\Repository\URLAliasService\listLocationAliases(), and eZ\Publish\Core\Repository\URLAliasService\load().

## ◆ isPathLoadable()

eZ\Publish\Core\Repository\URLAliasService::isPathLoadable | ( | array | $pathData,
|  | array | $languageCodes
| ) |  |
| protected

Returns true or false depending if URL alias is loadable or not for language settings in place.

Parameters

  array | $pathData |
  array | $languageCodes |

Returns
  bool

Definition at line 527 of file Core/Repository/URLAliasService.php.

Referenced by eZ\Publish\Core\Repository\URLAliasService\lookup().

## ◆ isUrlAliasLoadable()

eZ\Publish\Core\Repository\URLAliasService::isUrlAliasLoadable | ( | SPIURLAlias | $spiUrlAlias,
|  | ?string | $languageCode,
|  | bool | $showAllTranslations,
|  | array | $prioritizedLanguageList
| ) |  |
| protected

Returns true or false depending if URL alias is loadable or not for language settings in place.

Parameters

  \eZ\Publish\SPI\Persistence\Content\URLAlias | $spiUrlAlias |
  string | null | $languageCode |
  bool | $showAllTranslations |
  string[] | $prioritizedLanguageList |

Returns
  bool

Definition at line 488 of file Core/Repository/URLAliasService.php.

Referenced by eZ\Publish\Core\Repository\URLAliasService\listLocationAliases().

## ◆ listGlobalAliases()

eZ\Publish\Core\Repository\URLAliasService::listGlobalAliases | ( |  | $languageCode = `null`,
|  |  | $offset = `0`,
|  |  | $limit = `-1`
| ) |  |

List global aliases.

Parameters

  string | $languageCode | filters those which are valid for the given language
  int | $offset |
  int | $limit |

Returns
  \eZ\Publish\API\Repository\Values\Content\URLAlias[]

Implements eZ\Publish\API\Repository\URLAliasService.

Definition at line 557 of file Core/Repository/URLAliasService.php.

References eZ\Publish\Core\Repository\URLAliasService\buildUrlAliasDomainObject(), and eZ\Publish\Core\Repository\URLAliasService\extractPath().

## ◆ listLocationAliases()

eZ\Publish\Core\Repository\URLAliasService::listLocationAliases | ( | Location | $location,
|  |  | $custom = `true`,
|  |  | $languageCode = `null`,
|  |  | $showAllTranslations = `null`,
|  | array | $prioritizedLanguageList = `null`
| ) |  |

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

Parameters

  \eZ\Publish\API\Repository\Values\Content\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
  bool | null | $showAllTranslations | If enabled will include all alias as if they where always available.
  string[] | null | $prioritizedLanguageList | If set used as prioritized language codes, returning first match.

Returns
  \eZ\Publish\API\Repository\Values\Content\URLAlias[]

Definition at line 214 of file Core/Repository/URLAliasService.php.

References eZ\Publish\Core\Repository\URLAliasService\buildUrlAliasDomainObject(), eZ\Publish\Core\Repository\URLAliasService\extractPath(), and eZ\Publish\Core\Repository\URLAliasService\isUrlAliasLoadable().

Referenced by eZ\Publish\Core\Repository\URLAliasService\reverseLookup().

## ◆ load()

eZ\Publish\Core\Repository\URLAliasService::load | ( |  | $id | ) |

Loads URL alias by given $id.

Exceptions

Implements eZ\Publish\API\Repository\URLAliasService.

Definition at line 730 of file Core/Repository/URLAliasService.php.

References eZ\Publish\Core\Repository\URLAliasService\buildUrlAliasDomainObject(), and eZ\Publish\Core\Repository\URLAliasService\extractPath().

## ◆ lookup()

eZ\Publish\Core\Repository\URLAliasService::lookup | ( |  | $url,
|  |  | $languageCode = `null`
| ) |  |

looks up the URLAlias for the given url.

Exceptions

Implements eZ\Publish\API\Repository\URLAliasService.

Definition at line 652 of file Core/Repository/URLAliasService.php.

References eZ\Publish\Core\Repository\URLAliasService\buildUrlAliasDomainObject(), eZ\Publish\Core\Repository\URLAliasService\cleanUrl(), eZ\Publish\Core\Repository\URLAliasService\isPathLoadable(), and eZ\Publish\Core\Repository\URLAliasService\matchPath().

## ◆ matchLanguageCode()

eZ\Publish\Core\Repository\URLAliasService::matchLanguageCode | ( | array | $pathElementData,
|  |  | $pathElement
| ) |  |
| protected

Parameters

  array | $pathElementData |
  string | $pathElement |

Returns
  string|bool

Definition at line 436 of file Core/Repository/URLAliasService.php.

References eZ\Publish\Core\Repository\URLAliasService\sortTranslationsByPrioritizedLanguages().

Referenced by eZ\Publish\Core\Repository\URLAliasService\matchPath().

## ◆ matchPath()

eZ\Publish\Core\Repository\URLAliasService::matchPath | ( | SPIURLAlias | $spiUrlAlias,
|  |  | $path,
|  |  | $languageCode
| ) |  |
| protected

Matches path string with normalized path data returned from persistence.

Returns matched path string (possibly case corrected) and array of corresponding language codes or false if path could not be matched.

Parameters

  \eZ\Publish\SPI\Persistence\Content\URLAlias | $spiUrlAlias |
  string | $path |
  string | $languageCode |

Returns
  array

Definition at line 400 of file Core/Repository/URLAliasService.php.

References eZ\Publish\Core\Repository\URLAliasService\matchLanguageCode(), and eZ\Publish\Core\Repository\URLAliasService\selectAliasLanguageCode().

Referenced by eZ\Publish\Core\Repository\URLAliasService\lookup().

## ◆ refreshSystemUrlAliasesForLocation()

eZ\Publish\Core\Repository\URLAliasService::refreshSystemUrlAliasesForLocation | ( | Location | $location | ) |

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

Parameters

  \eZ\Publish\API\Repository\Values\Content\Location | $location |

Exceptions

Implements eZ\Publish\API\Repository\URLAliasService.

Definition at line 756 of file Core/Repository/URLAliasService.php.

References eZ\Publish\API\Repository\Values\Content\Location\getContent().

## ◆ removeAliases()

eZ\Publish\Core\Repository\URLAliasService::removeAliases | ( | array | $aliasList | ) |

Removes urls aliases.

This method does not remove autogenerated aliases for locations.

Exceptions

Implements eZ\Publish\API\Repository\URLAliasService.

Definition at line 595 of file Core/Repository/URLAliasService.php.

References eZ\Publish\Core\Repository\URLAliasService\buildSPIUrlAlias().

## ◆ reverseLookup()

eZ\Publish\Core\Repository\URLAliasService::reverseLookup | ( | Location | $location,
|  |  | $languageCode = `null`,
|  | bool | $showAllTranslations = `null`,
|  | array | $prioritizedLanguageList = `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.

Exceptions

Definition at line 680 of file Core/Repository/URLAliasService.php.

References eZ\Publish\Core\Repository\URLAliasService\listLocationAliases().

## ◆ selectAliasLanguageCode()

eZ\Publish\Core\Repository\URLAliasService::selectAliasLanguageCode | ( | SPIURLAlias | $spiUrlAlias,
|  | ?string | $languageCode,
|  | bool | $showAllTranslations,
|  | array | $prioritizedLanguageList
| ) |  |
| protected

Determines alias language code.

Method will return false if language code can't be matched against alias language codes or language settings.

Parameters

  \eZ\Publish\SPI\Persistence\Content\URLAlias | $spiUrlAlias |
  string | null | $languageCode |
  bool | $showAllTranslations |
  string[] | $prioritizedLanguageList |

Returns
  string|bool

Definition at line 287 of file Core/Repository/URLAliasService.php.

Referenced by eZ\Publish\Core\Repository\URLAliasService\extractPath(), and eZ\Publish\Core\Repository\URLAliasService\matchPath().

## ◆ sortTranslationsByPrioritizedLanguages()

eZ\Publish\Core\Repository\URLAliasService::sortTranslationsByPrioritizedLanguages | ( | array | $translations | ) |
| private

Needed when translations for the part of the alias are the same for multiple languages.

In that case we need to ensure that more prioritized language is chosen.

Parameters

  array | $translations |

Returns
  array

Definition at line 455 of file Core/Repository/URLAliasService.php.

Referenced by eZ\Publish\Core\Repository\URLAliasService\matchLanguageCode().

## Member Data Documentation

## ◆ $nameSchemaService

eZ\Publish\Core\Repository\URLAliasService::$nameSchemaService
| protected

Definition at line 39 of file Core/Repository/URLAliasService.php.

Referenced by eZ\Publish\Core\Repository\URLAliasService\__construct().

## ◆ $permissionResolver

eZ\Publish\Core\Repository\URLAliasService::$permissionResolver
| private

Definition at line 42 of file Core/Repository/URLAliasService.php.

Referenced by eZ\Publish\Core\Repository\URLAliasService\__construct().

## ◆ $repository

eZ\Publish\Core\Repository\URLAliasService::$repository
| protected

Definition at line 30 of file Core/Repository/URLAliasService.php.

Referenced by eZ\Publish\Core\Repository\URLAliasService\__construct().

## ◆ $settings

eZ\Publish\Core\Repository\URLAliasService::$settings
| protected

Definition at line 36 of file Core/Repository/URLAliasService.php.

Referenced by eZ\Publish\Core\Repository\URLAliasService\__construct().

## ◆ $urlAliasHandler

eZ\Publish\Core\Repository\URLAliasService::$urlAliasHandler
| protected

Definition at line 33 of file Core/Repository/URLAliasService.php.

Referenced by eZ\Publish\Core\Repository\URLAliasService\__construct().

The documentation for this class was generated from the following file:

- Core/Repository/URLAliasService.php

Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.