Drupal is a registered trademark of Dries Buytaert
Release: Drupal 10.3.6 Update released for Drupal core (10.3.6)! Release: Drupal 11.0.5 Update released for Drupal core (11.0.5)! Release: Drupal 10.2.9 Update released for Drupal core (10.2.9)! Release: Drupal 10.2.10 Update released for Drupal core (10.2.10)! Release: Drupal 10.3.7 Update released for Drupal core (10.3.7)! Release: Drupal 11.0.6 Update released for Drupal core (11.0.6)! Release: Drupal 10.3.8 Update released for Drupal core (10.3.8)! Release: Drupal 11.0.7 Update released for Drupal core (11.0.7)! Module Revived: Translation Management Tool 8.x-1.19 Module tmgmt updated after 7 months of inactivity (8.x-1.19). Usage Milestone: Account field split Module account_field_split crossed 10,000 active installs.

Provides some handy extra cache tags, so you can for example tag a block that deals with a certain node type, with the cache tag of that node type.

The module provides the following cache tags for you to use:

handy_cache_tags:[entity_type]
handy_cache_tags:[entity_type]:[entity_bundle]

For example with nodes of the bundle "article" this would make the following cache tags available:

handy_cache_tags:node
handy_cache_tags:node:article

The first would invalidate on any node (which by coincidence also is provided through the "node_list" cache tag in core). The second would invalidate on any node being created, updated or deleted with the bundle article.

To generate these tags for your render array, you can use the following:

$build['#cache'] = [
  'tags' => [
    // This one generates the bundle specific cache tag.
    \Drupal::service('handy_cache_tags.manager')->getBundleTag('node', 'article'),
    // This one generates the entity type cache tag.
    \Drupal::service('handy_cache_tags.manager')->getTag('node'),
  ],
];

If your render array deals with an entity, you can also use the following helper functions:

// Get all tags for an entity:
\Drupal::service('handy_cache_tags.manager')
  ->getEntityTags(EntityInterface $entity);

// Get entity type tag from an entity:
\Drupal::service('handy_cache_tags.manager')
  ->getEntityTypeTagFromEntity(EntityInterface $entity);

// Get bundle tag from entity:
\Drupal::service('handy_cache_tags.manager')
  ->getBundleTagFromEntity(EntityInterface $entity);

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
1
Tracked since
Oct 2024
Latest release
1 year ago
Releases (12 mo)
0 ▼ from 1
Maintenance
Dormant

Releases

Version Type Core Release date
8.x-1.5 Stable Oct 27, 2024