You are here

gridstack_ui.module in GridStack 8.2

Same filename and directory in other branches
  1. 8 modules/gridstack_ui/gridstack_ui.module

Provides GridStack configuration entity UI.

File

modules/gridstack_ui/gridstack_ui.module
View source
<?php

/**
 * @file
 * Provides GridStack configuration entity UI.
 */

/**
 * Implements hook_theme().
 */
function gridstack_ui_theme() {
  $themes['gridstack_ui_admin'] = [
    'render element' => 'element',
    'file' => 'templates/gridstack_ui.theme.inc',
  ];
  return $themes;
}

/**
 * Implements hook_entity_type_build().
 */
function gridstack_ui_entity_type_build(array &$entity_types) {

  /* @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */
  $gridstack = $entity_types['gridstack'];
  $gridstack
    ->setListBuilderClass('Drupal\\gridstack_ui\\Controller\\GridStackListBuilder');
  $gridstack
    ->setFormClass('add', 'Drupal\\gridstack_ui\\Form\\GridStackForm');
  $gridstack
    ->setFormClass('edit', 'Drupal\\gridstack_ui\\Form\\GridStackForm');
  $gridstack
    ->setFormClass('delete', 'Drupal\\gridstack_ui\\Form\\GridStackDeleteForm');
  $gridstack
    ->setFormClass('duplicate', 'Drupal\\gridstack_ui\\Form\\GridStackForm');
  $gridstack
    ->set('admin_permission', 'administer gridstack');
  $gridstack
    ->setLinkTemplate('add-form', '/admin/structure/gridstack/add');
  $gridstack
    ->setLinkTemplate('edit-form', '/admin/structure/gridstack/{gridstack}');
  $gridstack
    ->setLinkTemplate('delete-form', '/admin/structure/gridstack/{gridstack}/delete');
  $gridstack
    ->setLinkTemplate('duplicate-form', '/admin/structure/gridstack/{gridstack}/duplicate');
  $gridstack
    ->setLinkTemplate('collection', '/admin/structure/gridstack');

  /* @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */
  $gridstack_variant = $entity_types['gridstack_variant'];
  $gridstack_variant
    ->setListBuilderClass('Drupal\\gridstack_ui\\Controller\\GridStackVariantListBuilder');
  $gridstack_variant
    ->setFormClass('add', 'Drupal\\gridstack_ui\\Form\\GridStackVariantForm');
  $gridstack_variant
    ->setFormClass('edit', 'Drupal\\gridstack_ui\\Form\\GridStackVariantForm');
  $gridstack_variant
    ->setFormClass('delete', 'Drupal\\gridstack_ui\\Form\\GridStackVariantDeleteForm');
  $gridstack_variant
    ->setFormClass('duplicate', 'Drupal\\gridstack_ui\\Form\\GridStackVariantForm');
  $gridstack_variant
    ->set('admin_permission', 'administer gridstack variant');
  $gridstack_variant
    ->setLinkTemplate('add-form', '/admin/structure/gridstack/variant/{gridstack}/add');
  $gridstack_variant
    ->setLinkTemplate('edit-form', '/admin/structure/gridstack/variant/{gridstack}/{gridstack_variant}');
  $gridstack_variant
    ->setLinkTemplate('delete-form', '/admin/structure/gridstack/variant/{gridstack}/{gridstack_variant}/delete');
  $gridstack_variant
    ->setLinkTemplate('duplicate-form', '/admin/structure/gridstack/variant/{gridstack}/duplicate');
  $gridstack_variant
    ->setLinkTemplate('collection', '/admin/structure/gridstack/variant');
}

/**
 * Implements hook_help().
 */
function gridstack_ui_help($route_name) {
  if ($route_name == 'help.page.gridstack_ui') {
    $output = file_get_contents(dirname(dirname(dirname(__FILE__))) . '/docs/README.md');
    foreach ([
      'CONFIGURATION',
      'TROUBLESHOOTING',
      'FAQ',
      'ROADMAP',
    ] as $key) {
      $output .= file_get_contents(dirname(dirname(dirname(__FILE__))) . "/docs/{$key}.md");
    }
    return function_exists('blazy_parse_markdown') ? blazy_parse_markdown($output) : '<pre>' . $output . '</pre>';
  }
  return '';
}