class ConfigEntityStaticCacheTestHooks

Hook implementations for config_entity_static_cache_test.

Hierarchy

Expanded class hierarchy of ConfigEntityStaticCacheTestHooks

File

core/modules/config/tests/config_entity_static_cache_test/src/Hook/ConfigEntityStaticCacheTestHooks.php, line 13

Namespace

Drupal\config_entity_static_cache_test\Hook
View source
class ConfigEntityStaticCacheTestHooks {
  
  /**
   * Implements hook_ENTITY_TYPE_load() for 'static_cache_test_config_test'.
   */
  public function configTestLoad($entities) : void {
    static $random;
    if (!$random) {
      $random = new Random();
    }
    foreach ($entities as $entity) {
      // Add a random stamp for every load(), so that during tests, we can tell
      // if an entity was retrieved from cache (unchanged stamp) or reloaded.
      $entity->_loadStamp = $random->string(8, TRUE);
    }
  }
  
  /**
   * Implements hook_entity_type_alter().
   */
  public function entityTypeAlter(array &$entity_types) : void {
    /** @var \Drupal\Core\Entity\EntityTypeInterface[] $entity_types */
    $entity_types['config_test']->set('static_cache', TRUE);
  }

}

Members

Title Sort descending Modifiers Object type Summary
ConfigEntityStaticCacheTestHooks::configTestLoad public function Implements hook_ENTITY_TYPE_load() for 'static_cache_test_config_test'.
ConfigEntityStaticCacheTestHooks::entityTypeAlter public function Implements hook_entity_type_alter().

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.