config_entity_static_cache_test.module 855 B

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