function EndOfTransactionQueriesTest::userInsert

Same name and namespace in other branches
  1. 11.x core/tests/Drupal/KernelTests/Core/Cache/EndOfTransactionQueriesTest.php \Drupal\KernelTests\Core\Cache\EndOfTransactionQueriesTest::userInsert()

Implements hook_ENTITY_TYPE_insert().

Attributes

#[Hook('user_insert')]

See also

\Drupal\KernelTests\Core\Cache\EndOfTransactionQueriesTest::testEntitySave()

File

core/tests/Drupal/KernelTests/Core/Cache/EndOfTransactionQueriesTest.php, line 192

Class

EndOfTransactionQueriesTest
Tests delaying of cache tag invalidation queries to the end of transactions.

Namespace

Drupal\KernelTests\Core\Cache

Code

public function userInsert(UserInterface $entity) : void {
  if ($entity->getAccountName() === 'john doe') {
    // Read the in-transaction cache writes.
    // @see \Drupal\KernelTests\Core\Cache\EndOfTransactionQueriesTest::entityTestInsert()
    \Drupal::state()->set('delay_cache_tags_invalidation_user_insert__during_transaction_foobar', \Drupal::cache()->get('delay_cache_tags_invalidation_entity_test_insert__during_transaction_foobar'));
    \Drupal::state()->set('delay_cache_tags_invalidation_user_insert__during_transaction_entity_test_list', \Drupal::cache()->get('delay_cache_tags_invalidation_entity_test_insert__during_transaction_entity_test_list'));
  }
}

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