You are here

field_group_test.module in Field Group 8

Same filename and directory in other branches
  1. 8.3 tests/modules/field_group_test/field_group_test.module

Fieldgroup test module.

File

tests/modules/field_group_test/field_group_test.module
View source
<?php

use Drupal\Core\Access\AccessResult;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Session\AccountInterface;

/**
 * @file
 * Fieldgroup test module.
 */

/**
 * Implements hook_entity_field_access().
 */
function field_group_test_entity_field_access($operation, FieldDefinitionInterface $field_definition, AccountInterface $account, FieldItemListInterface $items = NULL) {

  // Set access to false for field_no_access.
  if ($operation == 'view' && $field_definition
    ->getName() == 'field_no_access') {
    return AccessResult::forbidden();
  }
  return AccessResult::neutral();
}