5 * Helper module for the diff tests.
8 use Drupal\Core\Access\AccessResult;
9 use Drupal\diff\Routing\DiffRouteProvider;
10 use Drupal\Core\Field\FieldDefinitionInterface;
11 use Drupal\Core\Session\AccountInterface;
12 use Drupal\Core\Field\FieldItemListInterface;
15 * Implements hook_entity_type_alter().
17 function diff_test_entity_type_alter(array &$entity_types) {
18 /** @var \Drupal\Core\Entity\EntityType $entity_type */
19 $entity_type = $entity_types['entity_test_rev'];
20 $handlers = $entity_type->get('handlers');
21 $handlers['route_provider']['html_diff'] = DiffRouteProvider::class;
22 $entity_type->set('handlers', $handlers);
23 $entity_type->setLinkTemplate('revisions-diff', "/entity_test_rev/{entity_test_rev}/revision/{left_revision}/{right_revision}");
27 * Implements hook_entity_field_access().
29 function diff_test_entity_field_access($operation, FieldDefinitionInterface $field_definition, AccountInterface $account, FieldItemListInterface $items = NULL) {
30 if ($field_definition->getName() == 'field_diff_deny_access') {
31 return AccessResult::forbidden();
33 return AccessResult::allowed();