public function CacheContextsManager::assertValidTokens
public CacheContextsManager::assertValidTokens($context_tokens)
Asserts the context tokens are valid
Similar to ::validateTokens, this method returns boolean TRUE when the context tokens are valid, and FALSE when they are not instead of returning NULL when they are valid and throwing a \LogicException when they are not. This function should be used with the assert() statement.
Parameters
mixed $context_tokens: Variable to be examined - should be array of context_tokens.
Return value
bool TRUE if context_tokens is an array of valid tokens.
File
- core/lib/Drupal/Core/Cache/Context/CacheContextsManager.php, line 310
Class
- CacheContextsManager
- Converts cache context tokens into cache keys.
Namespace
Drupal\Core\Cache\ContextCode
public function assertValidTokens($context_tokens) { if (!is_array($context_tokens)) { return FALSE; } try { $this->validateTokens($context_tokens); } catch (\LogicException $e) { return FALSE; } return TRUE; }
© 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!Context!CacheContextsManager.php/function/CacheContextsManager::assertValidTokens/8.1.x