link_fix_absolute_urls-1.0.2/link_fix_absolute_urls.module

link_fix_absolute_urls.module
<?php

/**
 * @file
 * Primary hook implementations for link_fix_absolute_urls.
 */

use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Routing\RouteMatchInterface;

/**
 * Implements hook_help().
 */
function link_fix_absolute_urls_help($route_name, RouteMatchInterface $route_match) {
  switch ($route_name) {
    // Main module help entry for the link_fix_absolute_urls module.
    case 'help.page.link_fix_absolute_urls':
      $output = '';
      $output .= '<h3>' . t('About') . '</h3>';
      $output .= '<p>' . t('Convert external URLs to internal paths.') . '</p>';
      return $output;
  }
}

/**
 * Implements hook_entity_presave().
 */
function link_fix_absolute_urls_entity_presave(EntityInterface $entity) {
  // Not every entity supports the getFieldDefinitions() method, so fail early
  // if this one does not.
  if (!method_exists($entity, 'getFieldDefinitions')) {
    return;
  }

  // Make sure that the getFieldDefinitions() method is callable, i.e. that it
  // is public.
  if (!is_callable([$entity, 'getFieldDefinitions'])) {
    return;
  }

  \Drupal::service('link_fix_absolute_urls.link_processor')
    ->process($entity);
}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc