You are here

blockgroup.module in Block Group 8

Same filename and directory in other branches
  1. 7.2 blockgroup.module
  2. 7 blockgroup.module

Block Group module hooks.

File

blockgroup.module
View source
<?php

/**
 * @file
 * Block Group module hooks.
 */
use Drupal\blockgroup\Entity\BlockGroupContent;

/**
 * Implements hook_help().
 */
function blockgroup_help($route_name) {
  switch ($route_name) {

    // Main module help for the blockgroup module.
    case 'help.page.blockgroup':
      $output = '';
      $output .= '<h3>' . t('About') . '</h3>';
      $output .= '<p>' . t('Add block groups to block configuration page') . '</p>';
      return $output;
    default:
  }
}

/**
 * Implements hook_system_info_alter().
 */
function blockgroup_system_info_alter(&$info, $file, $type) {
  if ($type == 'theme') {
    $info['regions'] += blockgroup_region_list();
  }
}

/**
 * Load all the block groups.
 *
 * @return array
 *   Returns the created block groups.
 */
function blockgroup_region_list() {
  $regions = [];

  /** @var \Drupal\blockgroup\BlockGroupContentInterface[] $blockgroups */
  $blockgroups = BlockGroupContent::loadMultiple();
  foreach ($blockgroups as $blockgroup) {
    $regions[$blockgroup
      ->id()] = (string) t('Block group: @label', [
      '@label' => $blockgroup
        ->label(),
    ]);
  }
  return $regions;
}

Functions

Namesort descending Description
blockgroup_help Implements hook_help().
blockgroup_region_list Load all the block groups.
blockgroup_system_info_alter Implements hook_system_info_alter().