public static function Cache::validateTags

public static Cache::validateTags(array $tags)

Validates an array of cache tags.

Can be called before using cache tags in operations, to ensure validity.

Parameters

string[] $tags: An array of cache tags.

Throws

\LogicException

Deprecated

Use assert('\Drupal\Component\Assertion\Inspector::assertAllStrings($tags)');

File

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

Class

Cache
Helper methods for cache.

Namespace

Drupal\Core\Cache

Code

public static function validateTags(array $tags) {
  if (empty($tags)) {
    return;
  }
  foreach ($tags as $value) {
    if (!is_string($value)) {
      throw new \LogicException('Cache tags must be strings, ' . gettype($value) . ' given.');
    }
  }
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Cache!Cache.php/function/Cache::validateTags/8.1.x