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

bt_cms.module
<?php

/**
 * @file
 * Module file for bt_cms.
 */

use Drupal\Core\Entity\EntityTypeInterface;

/**
 * Implements hook_menu_local_actions_alter().
 */
function bt_cms_menu_local_actions_alter(&$local_actions) {
  $local_actions['node.add_page']['appears_on'][0] = 'system.admin_content';
}

/**
 * Implements hook_entity_base_field_info_alter().
 */
function bt_cms_entity_base_field_info_alter(&$fields, EntityTypeInterface $entity_type) {
  if ($entity_type->id() == 'node') {
    if (isset($fields['title'])) {
      $fields['title']->setDisplayConfigurable('view', TRUE);
    }
  }
  // Alter the mymodule_text field to use a custom class.
  if ($entity_type->id() == 'block_content') {
    $fields['info']->setLabel('Block Name');
    $fields['info']->setDescription('The name by which the block will be displayed in the list of custom blocks.');
  }

}

/**
 * Implements hook_entity_type_alter().
 */
function bt_cms_entity_type_alter(array &$entity_types) {
  $entity_types['node']->setHandlerClass('route_provider', ['html' => 'Drupal\bt_cms\AlterNodeRouteProvider']);
  $entity_types['node']->setHandlerClass('view_builder', 'Drupal\bt_cms\CustomNodeViewBuilder');

}

/**
 * Implements hook_node_links_alter().
 */
function bt_cms_node_links_alter(&$links, $entity, &$context) {
  if ($entity->getEntityTypeId() == 'node') {
    $bundle = $entity->bundle();
    $view_mode = $context['view_mode'];
    $links['#theme'] = 'links__' . $bundle . '_' . $view_mode;
  }

}

/**
 * Implements hook_local_tasks_alter().
 */
function bt_cms_local_tasks_alter(&$local_tasks) {
  // Update content task to integrate it with our navigation structure.
  unset($local_tasks['comment.admin']);
  $local_tasks['system.admin_content']['base_route'] = 'bt_cms.website';
  $local_tasks['system.admin_content']['route_name'] = 'system.admin_content';
  $local_tasks['comment.admin_new']['parent_id'] = 'system.admin_content';
  $local_tasks['comment.admin_new']['weight'] = 2;
  $local_tasks['comment.admin_approval']['parent_id'] = 'system.admin_content';
  $local_tasks['comment.admin_approval']['weight'] = 3;

  // Make theme tabs name more specific.
  $local_tasks['system.themes_page']['title'] = 'Theme List';
  $local_tasks['system.theme_settings']['title'] = 'Theme Settings';

  // Disable default tabs of block_content.
  unset($local_tasks['entity.block_content.collection']);
  unset($local_tasks['block_content.list_sub']);
  unset($local_tasks['entity.block_content_type.collection']);

  // Move block.admin_display tabs to the system.themes_page tabs group.
  $local_tasks['block.admin_display']['base_route'] = 'system.themes_page';
  $local_tasks['block.admin_display']['weight'] = 200;
}

/**
 * Implements hook_menu_links_discovered_alter().
 */
function bt_cms_menu_links_discovered_alter(&$links) {
  // Move block.admin_display menu item inside to the
  // system.themes_page menu item.
  $links['block.admin_display']['parent'] = 'system.themes_page';
}

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

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