protected function assertDefaultCacheability(AccessResult $access) { $this->assertTrue($access->isCacheable()); $this->assertSame([], $access->getCacheKeys()); $this->assertSame([], $access->getCacheTags()); $this->assertSame('default', $access->getCacheBin()); $this->assertSame(Cache::PERMANENT, $access->getCacheMaxAge()); }
/** * Merges cacheable metadata from conditions onto the access result object. * * @param \Drupal\Core\Access\AccessResult $access * The access result object. * @param \Drupal\Core\Condition\ConditionInterface[] $conditions * List of visibility conditions. */ protected function mergeCacheabilityFromConditions(AccessResult $access, array $conditions) { foreach ($conditions as $condition) { if ($condition instanceof CacheableDependencyInterface) { $access->addCacheTags($condition->getCacheTags()); $access->addCacheContexts($condition->getCacheContexts()); $access->setCacheMaxAge(Cache::mergeMaxAges($access->getCacheMaxAge(), $condition->getCacheMaxAge())); } } }
protected function assertDefaultCacheability(AccessResult $access) { $this->assertSame([], $access->getCacheContexts()); $this->assertSame([], $access->getCacheTags()); $this->assertSame(Cache::PERMANENT, $access->getCacheMaxAge()); }