cloudflare_stream-8.x-1.0/cloudflare_stream.module

cloudflare_stream.module
<?php

/**
 * @file
 * Hook implementations for Cloudflare Stream module.
 */

use Drupal\Component\Utility\Html;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Routing\RouteMatchInterface;

/**
 * Implements hook_help().
 */
function cloudflare_stream_help($route_name, RouteMatchInterface $route_match) {
  switch ($route_name) {
    case 'help.page.cloudflare_stream':
      $text = file_get_contents(__DIR__ . '/README.md');
      if (!\Drupal::moduleHandler()->moduleExists('markdown')) {
        return '<pre>' . Html::escape($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');
      }
  }
  return NULL;
}

/**
 * Implements hook_theme().
 */
function cloudflare_stream_theme() {
  return [
    'cloudflare_video' => [
      'variables' => [
        'stream' => [],
        'description' => NULL,
      ],
      'template' => 'cloudflare-video',
    ],
  ];
}

/**
 * Implements hook_form_alter().
 */
function cloudflare_stream_form_alter(&$form, FormStateInterface $form_state, $form_id) {
  // Add the icon to field_ui form.
  if ($form_id === 'field_ui_field_storage_add_form') {
    $form['#attached']['library'][] = 'cloudflare_stream/cloudflare_stream.manage_fields';
  }
}

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

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