function pathauto_entity_update_alias in Pathauto Entity 7
Creates or updates entity alias.
Parameters
string $entity_type: Type of the entity the alias is being created/updated for.
object $entity: An entity object the alias is being created/updated for.
string $op: Operation being performed on the alias ('insert', 'update' or 'bulkupdate').
string|null $language: Additional parameter to set the language of the path.
Return value
The alias that was created.
3 calls to pathauto_entity_update_alias()
- pathauto_entity_bulk_update_batch_callback in includes/
pathauto_entity.batch.inc - Batch processing callback; Generate aliases for entities.
- pathauto_entity_entity_insert in ./
pathauto_entity.module - Implements hook_entity_insert().
- pathauto_entity_entity_update in ./
pathauto_entity.module - Implements hook_entity_update().
File
- ./
pathauto_entity.module, line 325 - Implements custom entity type support for Pathauto module.
Code
function pathauto_entity_update_alias($entity_type, $entity, $op, $language = NULL) {
// Skip processing if we are not managing this entity type.
$types = pathauto_entity_supported_entity_types();
if (!isset($types[$entity_type])) {
return;
}
// Skip processing if the user has disabled pathauto for the entity.
if (isset($entity->path['pathauto']) && empty($entity->path['pathauto'])) {
return;
}
// Skip processing if the entity has no pattern.
$entity_info = entity_get_info($entity_type);
list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
if (!pathauto_pattern_load_by_entity($entity_type, $bundle)) {
return;
}
if ($op === 'insert' && $entity_type != 'file') {
// @todo Remove the next line when http://drupal.org/node/1025870 is fixed.
unset($entity->uri);
}
// Make sure the language is set.
if (!isset($language)) {
$language = pathauto_entity_language($entity_type, $entity);
}
module_load_include('inc', 'pathauto');
$uri = entity_uri($entity_type, $entity);
return pathauto_create_alias($entity_type, $op, $uri['path'], array(
$entity_info['token type'] => $entity,
), $bundle, $language);
}