Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. CacheContextsManager.php

function CacheContextsManager::assertValidTokens

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.

1 call to CacheContextsManager::assertValidTokens()
CacheContextsManager::convertTokensToKeys in core/lib/Drupal/Core/Cache/Context/CacheContextsManager.php
Converts cache context tokens to cache keys.

File

core/lib/Drupal/Core/Cache/Context/CacheContextsManager.php, line 315

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) {
        return FALSE;
    }
    return TRUE;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal