function EntityCreateAccessCustomCidTest::setUpAccessCache
Setup the access cache on the entity handler for testing.
Parameters
\Drupal\Core\Entity\EntityAccessControlHandler $handler: The access control handler.
bool $in_cache: Whether to prefill the handler's access cache.
string $cid: The cache ID.
Return value
\ReflectionProperty A reflection of the handler's accessCache property.
Throws
\ReflectionException
2 calls to EntityCreateAccessCustomCidTest::setUpAccessCache()
- EntityCreateAccessCustomCidTest::testCustomCid in core/
tests/ Drupal/ Tests/ Core/ Entity/ Access/ EntityCreateAccessCustomCidTest.php - Tests the entity access control handler with a custom static cache ID.
- EntityCreateAccessCustomCidTest::testDefaultCid in core/
tests/ Drupal/ Tests/ Core/ Entity/ Access/ EntityCreateAccessCustomCidTest.php - Tests the entity access control handler caching with context.
File
-
core/
tests/ Drupal/ Tests/ Core/ Entity/ Access/ EntityCreateAccessCustomCidTest.php, line 98
Class
- EntityCreateAccessCustomCidTest
- Tests entity access control handler custom internal cache ID.
Namespace
Drupal\Tests\Core\Entity\AccessCode
protected function setUpAccessCache(EntityAccessControlHandler $handler, bool $in_cache, string $cid) : \ReflectionProperty {
$access_cache = new \ReflectionProperty($handler, 'accessCache');
$access_cache->setAccessible(TRUE);
$cache = [];
if ($in_cache) {
// Prefill the handler's internal static cache.
$cache = [
$this->account
->id() => [
$cid => [
$this->langcode => [
'create' => AccessResult::allowed(),
],
],
],
];
}
$access_cache->setValue($handler, $cache);
return $access_cache;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.