function Cache::buildTags

Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/Cache/Cache.php \Drupal\Core\Cache\Cache::buildTags()
  2. 10 core/lib/Drupal/Core/Cache/Cache.php \Drupal\Core\Cache\Cache::buildTags()
  3. 11.x core/lib/Drupal/Core/Cache/Cache.php \Drupal\Core\Cache\Cache::buildTags()

Build an array of cache tags from a given prefix and an array of suffixes.

Each suffix will be converted to a cache tag by appending it to the prefix, with a colon between them.

Parameters

string $prefix: A prefix string.

array $suffixes: An array of suffixes. Will be cast to strings.

string $glue: A string to be used as glue for concatenation. Defaults to a colon.

Return value

string[] An array of cache tags.

5 calls to Cache::buildTags()
CacheTest::testBuildTags in core/tests/Drupal/Tests/Core/Cache/CacheTest.php
@covers ::buildTags
MenuTreeStorage::rebuild in core/lib/Drupal/Core/Menu/MenuTreeStorage.php
Rebuilds the stored menu link definitions.
MenuTreeStorage::save in core/lib/Drupal/Core/Menu/MenuTreeStorage.php
Saves a plugin definition to the storage.
node_title_list in core/modules/node/node.module
Gathers a listing of links to nodes.
PermissionsHashGenerator::generate in core/lib/Drupal/Core/Session/PermissionsHashGenerator.php
Cached by role, invalidated whenever permissions change.

File

core/lib/Drupal/Core/Cache/Cache.php, line 96

Class

Cache
Helper methods for cache.

Namespace

Drupal\Core\Cache

Code

public static function buildTags($prefix, array $suffixes, $glue = ':') {
    $tags = [];
    foreach ($suffixes as $suffix) {
        $tags[] = $prefix . $glue . $suffix;
    }
    return $tags;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.