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\Context

Code

public function assertValidTokens($context_tokens) {
  if (!is_array($context_tokens)) {
    return FALSE;
  }

  try {
    $this->validateTokens($context_tokens);
  }
  catch (\LogicException $e) {
    return FALSE;
  }

  return TRUE;
}
doc_Drupal
2016-10-29 08:49:27
Comments
Leave a Comment

Please login to continue.