protected static function ContentLanguageSettingsTest::getExpectedCollectionCacheability in JSON:API 8.2
Same name and namespace in other branches
- 8 tests/src/Functional/ContentLanguageSettingsTest.php \Drupal\Tests\jsonapi\Functional\ContentLanguageSettingsTest::getExpectedCollectionCacheability()
Computes the cacheability for a given entity collection.
Parameters
\Drupal\Core\Session\AccountInterface $account: An account for which cacheability should be computed (cacheability is dependent on access).
\Drupal\Core\Entity\EntityInterface[] $collection: The entities for which cacheability should be computed.
array $sparse_fieldset: (optional) If a sparse fieldset is being requested, limit the expected cacheability for the collection entities' fields to just those in the fieldset. NULL means all fields.
bool $filtered: Whether the collection is filtered or not.
Return value
\Drupal\Core\Cache\CacheableMetadata The expected cacheability for the given entity collection.
Overrides ResourceTestBase::getExpectedCollectionCacheability
File
- tests/
src/ Functional/ ContentLanguageSettingsTest.php, line 145
Class
- ContentLanguageSettingsTest
- JSON:API integration test for "ContentLanguageSettings" config entity type.
Namespace
Drupal\Tests\jsonapi\FunctionalCode
protected static function getExpectedCollectionCacheability(AccountInterface $account, array $collection, array $sparse_fieldset = NULL, $filtered = FALSE) {
$cacheability = parent::getExpectedCollectionCacheability($account, $collection, $sparse_fieldset, $filtered);
if (static::entityAccess(reset($collection), 'view', $account)
->isAllowed()) {
$cacheability
->addCacheContexts([
'languages:language_interface',
]);
}
return $cacheability;
}