niobi-8.x-2.0-alpha4/modules/niobi_dashboards/niobi_dashboards.module

modules/niobi_dashboards/niobi_dashboards.module
<?php

/**
 * @file
 * Contains niobi_dashboards.module.
 */

use Drupal\Core\Routing\RouteMatchInterface;

/**
 * Implements hook_help().
 */
function niobi_dashboards_help($route_name, RouteMatchInterface $route_match) {
  switch ($route_name) {
    // Main module help for the niobi_dashboards module.
    case 'help.page.niobi_dashboards':
      $output = '';
      $output .= '<h3>' . t('About') . '</h3>';
      $output .= '<p>' . t('Provides base dashboards for Niobi Research Center') . '</p>';
      return $output;

    default:
  }
}

/**
 * Implements hook_entity_extra_field_info() to add the view fields to relevant entities
 */
function niobi_dashboards_entity_extra_field_info() {
  $ret = array();

  $ret['user']['user']['display']['niobi_user_dashboard'] = [
    'label' => t('User Dashboard'),
    'description' => t('User Dashboard'),
    'weight' => 10,
  ];

  return $ret;
}

/**
 * Implements hook_ENTITY_TYPE_view().
 */
function niobi_dashboards_user_view(array &$build, \Drupal\Core\Entity\EntityInterface $entity, \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display, $view_mode) {
  if ($display->getComponent('niobi_user_dashboard') && empty($build['profile_dashboard'])) {
    $build['profile_dashboard'] = [
      '#theme' => 'ajax_dashboard',
      '#id' => 'niobi_user_dashboard',
      '#params' => ['user' => $entity->id()]
    ];
  }
}

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

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