You are here

ldap_query.module in Lightweight Directory Access Protocol (LDAP) 8.4

File

ldap_query/ldap_query.module
View source
<?php

/**
 * @file
 * Module file for ldap_query.
 */
declare (strict_types=1);
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Entity\EntityInterface;

/**
 * Implements hook_help().
 */
function ldap_query_help($route_name, RouteMatchInterface $route_match) {
  $help = '<h3>' . t('LDAP Query Module') . '</h3><p>' . t('This module does nothing in and of itself.  It should only be
    enabled and configured if another module requires it.') . '</p>';
  if ($route_name === 'ldap_query.admin_form') {
    return '<p>' . $help . '</p>';
  }
}

/**
 * Implements hook_entity_operation().
 */
function ldap_query_entity_operation(EntityInterface $entity) : array {
  $operations = [];
  if (\Drupal::currentUser()
    ->hasPermission('administer ldap')) {
    if ($entity
      ->getEntityType()
      ->id() === 'ldap_query_entity') {
      $operations['query_test'] = [
        'title' => t('Test'),
        'weight' => 10,
        'url' => $entity
          ->toUrl('test'),
      ];
    }
  }
  return $operations;
}

Functions