You are here

function domain_path_form_alter in Domain Path 8

Same name and namespace in other branches
  1. 6 domain_path.module \domain_path_form_alter()

Implements hook_form_alter().

File

./domain_path.module, line 13
Path alias handling for multiple domains.

Code

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);
    }
  }
}