Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / config / tests / config_entity_static_cache_test / config_entity_static_cache_test.module
1 <?php
2
3 /**
4  * @file
5  * Provides configuration entity static cache test helpers.
6  */
7
8 use Drupal\Component\Utility\Random;
9
10 /**
11  * Implements hook_ENTITY_TYPE_load() for 'static_cache_test_config_test'.
12  */
13 function config_entity_static_cache_test_config_test_load($entities) {
14   static $random;
15   if (!$random) {
16     $random = new Random();
17   }
18   foreach ($entities as $entity) {
19     // Add a random stamp for every load(), so that during tests, we can tell
20     // if an entity was retrieved from cache (unchanged stamp) or reloaded.
21     $entity->_loadStamp = $random->string(8, TRUE);
22   }
23 }
24
25 /**
26  * Implements hook_entity_type_alter().
27  */
28 function config_entity_static_cache_test_entity_type_alter(array &$entity_types) {
29   /** @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */
30   $entity_types['config_test']->set('static_cache', TRUE);
31 }