Updated all the contrib modules to their latest versions.
[yaffs-website] / web / modules / contrib / diff / tests / modules / diff_test / diff_test.module
1 <?php
2
3 /**
4  * @file
5  * Helper module for the diff tests.
6  */
7
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;
13
14 /**
15  * Implements hook_entity_type_alter().
16  */
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}");
24 }
25
26 /**
27  * Implements hook_entity_field_access().
28  */
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();
32   }
33   return AccessResult::allowed();
34 }