gridstack-8.x-2.5/gridstack.module

gridstack.module
<?php

/**
 * @file
 * Provides GridStack integration to have multi-column grids with drag-and-drop.
 */

/**
 * Provides a convenient shortcut for procedural hooks.
 *
 * @return class
 *   The GridStack class instances.
 */
function gridstack($key = 'manager') {
  static $manager;
  static $hook;
  static $skin_manager;

  if (!isset($manager)) {
    $manager = \Drupal::service('gridstack.manager');
    $skin_manager = \Drupal::service('gridstack.skin_manager');
  }

  switch ($key) {
    case 'hook':
      if (!isset($hook)) {
        $hook = \Drupal::service('gridstack.hook');
      }
      return $hook;

    case 'skin':
      return $skin_manager;

    default:
      return $manager;
  }
}

/**
 * Implements hook_theme().
 */
function gridstack_theme() {
  $themes = [];
  foreach (['gridstack', 'box'] as $item) {
    $key = $item == 'gridstack' ? $item : 'gridstack_' . $item;
    $themes[$key] = [
      'render element' => 'element',
      'file' => 'templates/gridstack.theme.inc',
    ];
  }
  return $themes;
}

/**
 * Implements hook_library_info_build().
 */
function gridstack_library_info_build() {
  return gridstack('skin')->libraryInfoBuild();
}

/**
 * Implements hook_library_info_alter().
 */
function gridstack_library_info_alter(&$libraries, $extension) {
  if ($extension === 'gridstack') {
    gridstack('hook')->libraryInfoAlter($libraries, $extension);
  }
}

/**
 * Implements hook_field_formatter_info_alter().
 */
function gridstack_field_formatter_info_alter(array &$info) {
  gridstack('hook')->fieldFormatterInfoAlter($info);
}

/**
 * Implements hook_layout_alter().
 */
function gridstack_layout_alter(&$definitions) {
  gridstack('hook')->layoutAlter($definitions);
}

/**
 * Provides a wrapper to replace deprecated libraries_get_path() at ease.
 *
 * @todo remove and replace with blazy_libraries_get_path() post blazy:8.x-2.0.
 */
function gridstack_libraries_get_path($name, $base_path = FALSE) {
  if (function_exists('blazy_libraries_get_path')) {
    return blazy_libraries_get_path($name, $base_path);
  }
  $function = 'libraries_get_path';
  return is_callable($function) ? $function($name, $base_path) : FALSE;
}

/**
 * Implements hook_config_schema_info_alter().
 */
function gridstack_config_schema_info_alter(array &$definitions) {
  if (isset($definitions['gridstack_vanilla']) || isset($definitions['layout_plugin.settings']) || isset($definitions['core.entity_view_display.*.*.*.third_party.ds'])) {
    gridstack('hook')->configSchemaInfoAlter($definitions);
  }
}

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

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