graph_element-1.0.4/graph_element.module

graph_element.module
<?php

/**
 * @file
 * An graph of how to create custom Site Studio elements.
 */

use Drupal\Core\Routing\RouteMatchInterface;

/**
 * Implements hook_help().
 */
function graph_element_help($route_name, RouteMatchInterface $route_match) {
  switch ($route_name) {
    // Main module help for the cohesion_templates module.
    case 'help.page.graph_element':
      $text = file_get_contents(dirname(__FILE__) . '/README.md');
      if (!\Drupal::moduleHandler()->moduleExists('markdown')) {
        \Drupal::messenger()->addMessage('To view this page correctly, please
      install and enable the markdown module.');
        return '<pre>' . $text . '</pre>';
      }
      else {
        // Use the Markdown filter to render the README.
        $filter_manager = \Drupal::service('plugin.manager.filter');
        $settings = \Drupal::configFactory()->get('markdown.settings')->getRawData();
        $config = ['settings' => $settings];
        $filter = $filter_manager->createInstance('markdown', $config);
        return $filter->process($text, 'en');
      }
  }
}

/**
 * Implements hook_theme().
 */
function graph_element_theme($existing, $type, $theme, $path) {
  if (!\Drupal::moduleHandler()->moduleExists('cohesion')) {
    return [];
  }
  else {
    return [
      'graph_element' => [
        'template' => 'graph-element-template',
        'variables' => [
          'elementSettings' => NULL,
          'elementMarkup' => NULL,
          'elementContext' => NULL,
          'elementClass' => NULL,
          'elementChildren' => NULL,
        ],
        'render element' => 'children',
      ],
    ];
  }
}

/**
 * Implements hook_chart_alter().
 */
function graph_element_chart_alter(array &$element, $chart_id) {
  // Please note: this will only show when the charts_highcharts module is
  // enabled and Highcharts is set as your default library.
  if ($chart_id && (str_starts_with($chart_id, 'graph_element_') || str_starts_with($chart_id, 'graph_block_') || str_starts_with($chart_id, 'graph_field_'))) {
    $element['#attached']['library'][] = 'graph_element/graph_element';
  }
}

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

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