function CacheTestController::bundleTags
Bundle listing tags invalidation.
Parameters
string $entity_type_id: The entity type ID.
string $bundle: The bundle.
Return value
array Renderable array.
1 string reference to 'CacheTestController::bundleTags'
- cache_test.routing.yml in core/
modules/ system/ tests/ modules/ cache_test/ cache_test.routing.yml - core/modules/system/tests/modules/cache_test/cache_test.routing.yml
File
-
core/
modules/ system/ tests/ modules/ cache_test/ src/ Controller/ CacheTestController.php, line 33
Class
- CacheTestController
- Controller routines for cache_test routes.
Namespace
Drupal\cache_test\ControllerCode
public function bundleTags($entity_type_id, $bundle) {
$storage = \Drupal::entityTypeManager()->getStorage($entity_type_id);
$entity_ids = $storage->getQuery()
->condition('type', $bundle)
->execute();
$page = [];
$entities = $storage->loadMultiple($entity_ids);
foreach ($entities as $entity) {
$page[$entity->id()] = [
'#markup' => $entity->label(),
];
}
$page['#cache']['tags'] = [
$entity_type_id . '_list:' . $bundle,
];
return $page;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.