domain_path.module in Domain Path 8
Same filename and directory in other branches
Path alias handling for multiple domains.
File
domain_path.moduleView source
<?php
/**
* @file
* Path alias handling for multiple domains.
*/
use Drupal\Core\Entity\EntityInterface;
/**
* Implements hook_form_alter().
*/
function domain_path_form_alter(&$form, &$form_state, $form_id) {
// We really only want to alter entity forms with the path widget on it since
// we're editing path aliases.
if (isset($form['path']['widget']) && ($object = $form_state
->getFormObject()) && !empty($object) && is_callable([
$object,
'getEntity',
]) && ($entity = $object
->getEntity())) {
$domain_path_helper = \Drupal::service('domain_path.helper');
if ($domain_path_helper
->domainPathsIsEnabled($entity)) {
$domain_path_helper
->alterEntityForm($form, $form_state, $entity);
}
}
}
/**
* Implements hook_entity_delete().
*/
function domain_path_entity_delete(EntityInterface $entity) {
\Drupal::service('domain_path.helper')
->deleteEntityDomainPaths($entity, TRUE);
}
/**
* Implements hook_entity_translation_delete().
*/
function domain_path_entity_translation_delete(EntityInterface $translation) {
\Drupal::service('domain_path.helper')
->deleteEntityDomainPaths($translation);
}
Functions
Name | Description |
---|---|
domain_path_entity_delete | Implements hook_entity_delete(). |
domain_path_entity_translation_delete | Implements hook_entity_translation_delete(). |
domain_path_form_alter | Implements hook_form_alter(). |