rwprofile-3.0.x-dev/modules/hero_intro/hero_intro.module

modules/hero_intro/hero_intro.module
<?php

use Drupal\user\Entity\Role;
use Drupal\shortcut\Entity\Shortcut;

/**
 * Implements hook_theme().
 */
function hero_intro_theme($existing, $type, $theme, $path) {
  return [
    'node__intro' => [
      'template' => 'node--intro',
      'base hook' => 'node',
    ],
    'block__views_block__intro_block_1' => [
      'template' => 'block--views-block--intro-block-1',
      'base hook' => 'block',
    ],
  ];
}

/**
 * Implements hook_install().
 */
function hero_intro_install() {
  // Grant permissions to the Content Editor role.
  $role = Role::load('content_editor');
  if ($role) {
    $permissions = [
      'create intro content',
      'edit own intro content',
      'delete own intro content',
    ];
    foreach ($permissions as $permission) {
      $role->grantPermission($permission);
    }
    $role->save();
  }

  // Add a shortcut to the default shortcut set.
  $shortcut_set = \Drupal::entityTypeManager()->getStorage('shortcut_set')->load('default');
  if ($shortcut_set) {
    $shortcut = Shortcut::create([
      'shortcut_set' => $shortcut_set->id(),
      'link' => ['uri' => 'internal:/admin/intro/weight'],
      'title' => 'Sort Intro Content',
      'weight' => 0,
    ]);
    $shortcut->save();
  }
}

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

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