public static function Cache::validateTags in Drupal 8
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
in drupal:8.0.0 and is removed from drupal:9.0.0. Use assert(\Drupal\Component\Assertion\Inspector::assertAllStrings($tags)) instead.
1 call to Cache::validateTags()
- CacheTest::testValidateTags in core/
tests/ Drupal/ Tests/ Core/ Cache/ CacheTest.php - @covers ::validateTags
File
- core/
lib/ Drupal/ Core/ Cache/ Cache.php, line 105
Class
- Cache
- Helper methods for cache.
Namespace
Drupal\Core\CacheCode
public static function validateTags(array $tags) {
@trigger_error(__NAMESPACE__ . '\\Cache::validateTags() is deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. Use assert(\\Drupal\\Component\\Assertion\\Inspector::assertAllStrings($tags)) instead.', E_USER_DEPRECATED);
if (empty($tags)) {
return;
}
foreach ($tags as $value) {
if (!is_string($value)) {
throw new \LogicException('Cache tags must be strings, ' . gettype($value) . ' given.');
}
}
}