eZPublishCommunityProject  2012.12
eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler Class Reference

The UrlAlias Handler provides nice urls management. More...

+ Inheritance diagram for eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler:
+ Collaboration diagram for eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler:

Public Member Functions

 __construct (Gateway $gateway, Mapper $mapper, LocationGateway $locationGateway, LanguageHandler $languageHandler, TransformationProcessor $transformationProcessor, array $configuration=array())
 Creates a new UrlAlias Handler. More...
 
 createCustomUrlAlias ($locationId, $path, $forwarding=false, $languageCode=null, $alwaysAvailable=false)
 Create a user chosen $alias pointing to $locationId in $languageCode. More...
 
 createGlobalUrlAlias ($resource, $path, $forwarding=false, $languageCode=null, $alwaysAvailable=false)
 Create a user chosen $alias pointing to a resource in $languageCode. More...
 
 listGlobalURLAliases ($languageCode=null, $offset=0, $limit=-1)
 List global aliases. More...
 
 listURLAliasesForLocation ($locationId, $custom=false)
 List of user generated or autogenerated url entries, pointing to $locationId. More...
 
 loadUrlAlias ($id)
 Loads URL alias by given $id. More...
 
 locationCopied ($locationId, $newLocationId, $newParentId)
 Notifies the underlying engine that a location has moved. More...
 
 locationDeleted ($locationId)
 Notifies the underlying engine that a location was deleted or moved to trash. More...
 
 locationMoved ($locationId, $oldParentId, $newParentId)
 Notifies the underlying engine that a location has moved. More...
 
 lookup ($url)
 Looks up a url alias for the given url. More...
 
 removeURLAliases (array $urlAliases)
 Removes url aliases. More...
 
- Public Member Functions inherited from eZ\Publish\SPI\Persistence\Content\UrlAlias\Handler
 publishUrlAliasForLocation ($locationId, $parentLocationId, $name, $languageCode, $alwaysAvailable=false)
 This method creates or updates an urlalias from a new or changed content name in a language (if published). More...
 

Protected Member Functions

 cleanupText ($text, $method)
 Cleans up. More...
 
 convertToAlias ($text, $defaultValue="_1", $transformation=null)
 Converts the path $urlElement into a new alias url which only consists of valid characters in the URL. More...
 
 copySubtree ($actionMap, $oldParentAliasId, $newParentAliasId)
 Recursively copies aliases from old parent under new parent. More...
 
 createUrlAlias ($action, $path, $forward, $languageCode, $alwaysAvailable)
 Internal method for creating global or custom URL alias (these are handled in the same way) More...
 
 getCopiedLocationsMap ($oldParentId, $newParentId)
 
 getHash ($text)
 
 getRealAliasId ($locationId)
 Returns possibly corrected alias id for given $locationId. More...
 
 getUniqueCounterValue ($text, $parentId)
 Returns unique counter number that is appended to the path element in order to make it unique against system reserved names and other entries on the same level. More...
 
 getWordSeparator ()
 Returns word separator value. More...
 
 insertNopEntry ($parentId, $text, $textMD5)
 Convenience method for inserting nop type row. More...
 
 removeSubtree ($parentId, $action)
 Recursively removes aliases by given parent id and action. More...
 

Protected Attributes

 $configuration
 
 $gateway
 
 $languageHandler
 
 $locationGateway
 
 $mapper
 
 $transformationProcessor
 

Detailed Description

The UrlAlias Handler provides nice urls management.

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

Constructor & Destructor Documentation

eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::__construct ( Gateway  $gateway,
Mapper  $mapper,
LocationGateway  $locationGateway,
LanguageHandler  $languageHandler,
TransformationProcessor  $transformationProcessor,
array  $configuration = array() 
)

Creates a new UrlAlias Handler.

Parameters
\eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Gateway$gateway
\eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Mapper$mapper
\eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway$locationGateway
\eZ\Publish\Core\Persistence\Legacy\Content\Language\Handler$languageHandler
\eZ\Publish\Core\Persistence\Legacy\Content\Search\TransformationProcessor$transformationProcessor
array$configuration

Member Function Documentation

eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::cleanupText (   $text,
  $method 
)
protected

Cleans up.

Parameters
string$text
string$method
Returns
string

Referenced by eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler\convertToAlias().

eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::convertToAlias (   $text,
  $defaultValue = "_1",
  $transformation = null 
)
protected

Converts the path $urlElement into a new alias url which only consists of valid characters in the URL.

For non-Unicode setups this means character in the range a-z, numbers and _, for Unicode setups it means all characters except space, &, ;, /, :, =, ?, [, ], (, ), -

Invalid characters are converted to -.

Example with a non-Unicode setup

'My car' => 'My-car' 'What is this?' => 'What-is-this' 'This & that' => 'This-that' 'myfile.tpl' => 'Myfile-tpl', 'øæå' => 'oeaeaa'

Parameters
string$text
string$defaultValue
string | null$transformation
Returns
string

Referenced by eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler\createUrlAlias(), and eZ\Publish\SPI\Persistence\Content\UrlAlias\Handler\publishUrlAliasForLocation().

eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::copySubtree (   $actionMap,
  $oldParentAliasId,
  $newParentAliasId 
)
protected

Recursively copies aliases from old parent under new parent.

Parameters
array$actionMap
mixed$oldParentAliasId
mixed$newParentAliasId
Returns
void

Referenced by eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler\locationCopied().

eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::createCustomUrlAlias (   $locationId,
  $path,
  $forwarding = false,
  $languageCode = null,
  $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
boolean$forwarding
string$languageCode
boolean$alwaysAvailable
Returns

Implements eZ\Publish\SPI\Persistence\Content\UrlAlias\Handler.

eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::createGlobalUrlAlias (   $resource,
  $path,
  $forwarding = false,
  $languageCode = null,
  $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.

Exceptions
\eZ\Publish\API\Repository\Exceptions\ForbiddenExceptionif the path already exists for the given language
Parameters
string$resource
string$path
boolean$forwarding
string$languageCode
boolean$alwaysAvailable
Returns

Implements eZ\Publish\SPI\Persistence\Content\UrlAlias\Handler.

eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::createUrlAlias (   $action,
  $path,
  $forward,
  $languageCode,
  $alwaysAvailable 
)
protected

Internal method for creating global or custom URL alias (these are handled in the same way)

Exceptions
\eZ\Publish\Core\Base\Exceptions\ForbiddenExceptionif the path already exists for the given language
Parameters
string$action
string$path
boolean$forward
string | null$languageCode
boolean$alwaysAvailable
Returns

Referenced by eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler\createCustomUrlAlias(), and eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler\createGlobalUrlAlias().

eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::getCopiedLocationsMap (   $oldParentId,
  $newParentId 
)
protected
Parameters
mixed$oldParentId
mixed$newParentId
Returns
array

Referenced by eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler\locationCopied().

eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::getHash (   $text)
protected
eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::getRealAliasId (   $locationId)
protected

Returns possibly corrected alias id for given $locationId.

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)

Parameters
mixed$locationId
Returns
int

Referenced by eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler\locationCopied(), eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler\locationMoved(), and eZ\Publish\SPI\Persistence\Content\UrlAlias\Handler\publishUrlAliasForLocation().

eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::getUniqueCounterValue (   $text,
  $parentId 
)
protected

Returns unique counter number that is appended to the path element in order to make it unique against system reserved names and other entries on the same level.

Comparison is done only if parent element id is 0 (meaning that entry is at first path element). In a case when reserved name is matched method will return 2. When parent element id is not 0 or when there is no match with reserved names this will return 1, which is default value not appended to name. Note: this is used only when publishing URL aliases, when creating global and custom aliases user is allowed to create first level entries that collide with reserved names. Also, in actual creation of the alias name will be further checked against existing elements under the same parent, using unique counter value determined here as starting unique counter value.

Parameters
string$text
int$parentId
Returns
int

Referenced by eZ\Publish\SPI\Persistence\Content\UrlAlias\Handler\publishUrlAliasForLocation().

eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::getWordSeparator ( )
protected

Returns word separator value.

Returns
string

Referenced by eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler\cleanupText().

eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::insertNopEntry (   $parentId,
  $text,
  $textMD5 
)
protected

Convenience method for inserting nop type row.

Parameters
mixed$parentId
string$text
string$textMD5
Returns
mixed

Referenced by eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler\createUrlAlias().

eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::listGlobalURLAliases (   $languageCode = null,
  $offset = 0,
  $limit = -1 
)

List global aliases.

Parameters
string | null$languageCode
int$offset
int$limit
Returns
[]

Implements eZ\Publish\SPI\Persistence\Content\UrlAlias\Handler.

eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::listURLAliasesForLocation (   $locationId,
  $custom = false 
)

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

Parameters
mixed$locationId
boolean$customif true the user generated aliases are listed otherwise the autogenerated
Returns
[]

Implements eZ\Publish\SPI\Persistence\Content\UrlAlias\Handler.

eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::loadUrlAlias (   $id)

Loads URL alias by given $id.

Exceptions
\eZ\Publish\API\Repository\Exceptions\NotFoundException
Parameters
string$id
Returns

Implements eZ\Publish\SPI\Persistence\Content\UrlAlias\Handler.

eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::locationCopied (   $locationId,
  $newLocationId,
  $newParentId 
)

Notifies the underlying engine that a location has moved.

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

Parameters
mixed$locationId
mixed$oldParentId
mixed$newParentId
Returns
void

Implements eZ\Publish\SPI\Persistence\Content\UrlAlias\Handler.

eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::locationDeleted (   $locationId)

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

Parameters
mixed$locationId

Implements eZ\Publish\SPI\Persistence\Content\UrlAlias\Handler.

eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::locationMoved (   $locationId,
  $oldParentId,
  $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
Returns
void

Implements eZ\Publish\SPI\Persistence\Content\UrlAlias\Handler.

eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::lookup (   $url)

Looks up a url alias for the given url.

Exceptions
\eZ\Publish\API\Repository\Exceptions\NotFoundException
\RuntimeException
\eZ\Publish\Core\Base\Exceptions\NotFoundException
Parameters
string$url
Returns

Implements eZ\Publish\SPI\Persistence\Content\UrlAlias\Handler.

eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::removeSubtree (   $parentId,
  $action 
)
protected

Recursively removes aliases by given parent id and action.

Parameters
mixed$parentId
string$action
Returns
void

Referenced by eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler\locationDeleted().

eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::removeURLAliases ( array  $urlAliases)

Removes url aliases.

Autogenerated aliases are not removed by this method.

Parameters
\eZ\Publish\SPI\Persistence\Content\UrlAlias[]$urlAliases
Returns
boolean

Implements eZ\Publish\SPI\Persistence\Content\UrlAlias\Handler.

Member Data Documentation

eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::$configuration
protected
eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::$gateway
protected
eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::$languageHandler
protected
eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::$locationGateway
protected
eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::$mapper
protected
eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::$transformationProcessor
protected

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