bridtv-8.x-1.x-dev/bridtv.module

bridtv.module
<?php

/**
 * @file
 * Brid.TV integration module file.
 */

use Drupal\Component\Utility\Crypt;

/**
 * Implements hook_theme().
 */
function bridtv_theme($existing, $type, $theme, $path) {
  return [
    'bridtv_js' => [
      // The embedding key must be a type of BridEmbeddingInstance.
      'variables' => ['embedding' => NULL],
    ],
    'bridtv_amp' => [
      'variables' => ['embedding' => NULL],
    ],
    'bridtv_fia' => [
      'variables' => ['embedding' => NULL],
    ],

    // Playlist.
    'bridtv_playlist_js' => [
      // The embedding key must be a type of BridEmbeddingInstance.
      'variables' => ['embedding' => NULL],
    ],
    'bridtv_playlist_fia' => [
      // The embedding key must be a type of BridEmbeddingInstance.
      'variables' => ['embedding' => NULL],
    ],
    'bridtv_playlist_amp' => [
      'variables' => ['embedding' => NULL],
    ],
  ];
}

/**
 * Preprocess hook for bridtv_js render elements.
 */
function template_preprocess_bridtv_js(&$variables) {
  $variables['id'] = 'brid-' . Crypt::randomBytesBase64(8);
  $variables['#attached']['library'][] = 'bridtv/play';
}

/**
 * Preprocess hook for bridtv_fia render elements.
 */
function template_preprocess_bridtv_fia(&$variables) {
  $variables['id'] = 'brid-' . Crypt::randomBytesBase64(8);
}

/**
 * Preprocess hook for bridtv_amp render elements.
 */
function template_preprocess_bridtv_amp(&$variables) {
  $variables['settings'] = \Drupal::config('bridtv.settings')->getRawData();
  $variables['#attached']['library'][] = 'bridtv/amp';
}

/**
 * Preprocess hook for bridtv_js render elements.
 */
function bridtv_preprocess_bridtv_playlist_fia(&$variables) {
  $variables['id'] = 'brid-' . Crypt::randomBytesBase64(8);
}

/**
 * Preprocess hook for bridtv_js render elements.
 */
function bridtv_preprocess_bridtv_playlist_js(&$variables) {
  $variables['settings'] = \Drupal::config('bridtv.settings')->getRawData();
  $variables['id'] = 'brid-' . Crypt::randomBytesBase64(8);
  $variables['#attached']['library'][] = 'bridtv/play_playlist';
}

/**
 * Preprocess hook for bridtv_amp render elements.
 */
function bridtv_preprocess_bridtv_playlist_amp(&$variables) {
  $variables['settings'] = \Drupal::config('bridtv.settings')->getRawData();
  $variables['#attached']['library'][] = 'bridtv/amp';
}

/**
 * Implements hook_cron().
 */
function bridtv_cron() {
  $settings = \Drupal::config('bridtv.settings');
  if (!$settings->get('cron_sync')) {
    return;
  }

  /** @var \Drupal\bridtv\BridSync $sync */
  $sync = \Drupal::service('bridtv.sync');
  $sync->run(5);

  /** @var \Drupal\bridtv\BridPlaylistSync $sync */
  $sync = \Drupal::service('bridtv.playlist_sync');
  $sync->run(5);

  \Drupal::logger('bridtv')->info('Finished Brid.TV cron synchronization.');
}

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

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