replace-8.x-1.0/replace.module

replace.module
<?php

/**
 * @file
 * Add an URL formatter for image field
 */

use Drupal\Component\Utility\Unicode;
use Drupal\image\Entity\ImageStyle;
use Drupal\Core\Link;
use Drupal\Core\Url;

/**
 * Implements hook_theme().
 */
function replace_theme()
{
  return array(
    'replace_list' => array(
      'variables' => ['content' => NULL],
    ),
  );
}

function template_preprocess_replace_list(&$variables)
{
  $variables['types'] = [];
  if (!empty($variables['content'])) {
    foreach ($variables['content'] as $type) {
      $variables['types'][$type->id()] = [
        'type' => $type->id(),
        'add_link' => Link::fromTextAndUrl($type->label(), Url::fromRoute('replace.replace', ['node_type' => $type->id()]))->toString(),
        'description' => [
          '#markup' => $type->getDescription(),
        ],
      ];
    }
  }
}

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

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