media_library_test.module in Drupal 8
Same filename and directory in other branches
Contains hook implementations for the media_library_test module.
File
core/modules/media_library/tests/modules/media_library_test/media_library_test.moduleView source
<?php
/**
* @file
* Contains hook implementations for the media_library_test module.
*/
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\media_library_test\Form\TestNodeFormOverride;
/**
* Implements hook_entity_field_access().
*/
function media_library_test_entity_field_access($operation, FieldDefinitionInterface $field_definition, AccountInterface $account, FieldItemListInterface $items = NULL) {
return AccessResult::forbiddenIf($field_definition
->getName() === 'field_media_no_access', 'Field access denied by test module');
}
/**
* Implements hook_entity_type_alter().
*/
function media_library_test_entity_type_alter(array &$entity_types) {
if (isset($entity_types['node'])) {
$entity_types['node']
->setFormClass('default', TestNodeFormOverride::class);
$entity_types['node']
->setFormClass('edit', TestNodeFormOverride::class);
}
}
Functions
Name | Description |
---|---|
media_library_test_entity_field_access | Implements hook_entity_field_access(). |
media_library_test_entity_type_alter | Implements hook_entity_type_alter(). |