-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdomain_path.module
executable file
·38 lines (33 loc) · 1.11 KB
/
domain_path.module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?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);
}