Upgraded drupal core with security updates
[yaffs-website] / web / core / modules / rest / tests / modules / rest_test / rest_test.module
1 <?php
2
3 /**
4  * @file
5  * Contains hook implementations for testing REST module.
6  */
7
8 use Drupal\Core\Field\FieldDefinitionInterface;
9 use Drupal\Core\Session\AccountInterface;
10 use Drupal\Core\Field\FieldItemListInterface;
11 use Drupal\Core\Access\AccessResult;
12
13 /**
14  * Implements hook_entity_field_access().
15  *
16  * @see \Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase::setUp()
17  * @see \Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase::testPost()
18  */
19 function rest_test_entity_field_access($operation, FieldDefinitionInterface $field_definition, AccountInterface $account, FieldItemListInterface $items = NULL) {
20   if ($field_definition->getName() === 'field_rest_test') {
21     switch ($operation) {
22       case 'view':
23         // Never ever allow this field to be viewed: this lets EntityResourceTestBase::testGet() test in a "vanilla" way.
24         return AccessResult::forbidden();
25       case 'edit':
26         return AccessResult::forbidden();
27     }
28   }
29
30   // No opinion.
31   return AccessResult::neutral();
32 }