You are here

function pathauto_i18n_taxonomy_pathauto_alias_alter in Pathauto i18n 8

Same name and namespace in other branches
  1. 7 modules/pathauto_i18n_taxonomy/pathauto_i18n_taxonomy.module \pathauto_i18n_taxonomy_pathauto_alias_alter()

Implements hook_pathauto_alias_alter().

File

modules/pathauto_i18n_taxonomy/pathauto_i18n_taxonomy.module, line 104
Provides tools for creating multilanguage aliases for taxonomy terms.

Code

function pathauto_i18n_taxonomy_pathauto_alias_alter(&$alias, &$context) {
  $operations = array(
    'insert',
    'update',
    'bulkupdate',
  );

  // Skip insert of alias for all languages.
  if (!empty($context['module']) && ($context['module'] == 'term' || $context['module'] == 'taxonomy_term') && in_array($context['op'], $operations)) {
    $entity = FALSE;

    // On creating taxonomy term has term key on updating taxonomy_term.
    if (!empty($context['data']['term'])) {
      $entity = $context['data']['term'];
    }
    if (!empty($context['data']['taxonomy_term'])) {
      $entity = $context['data']['taxonomy_term'];
    }

    // Run bulk update.
    if ($context['op'] == 'bulkupdate') {
      pathauto_i18n_taxonomy_taxonomy_term_update($entity);
    }
    if ($entity && isset($entity->path['pathauto_i18n_status']) && $entity->path['pathauto_i18n_status'] && $context['language'] == LANGUAGE_NONE) {
      $alias = '';
    }
  }
}