You are here

public function ContextManager::contextExists in Context 8.0

Same name and namespace in other branches
  1. 8.4 src/ContextManager.php \Drupal\context\ContextManager::contextExists()
  2. 8 src/ContextManager.php \Drupal\context\ContextManager::contextExists()

Check to validate that the context name does not already exist.

Parameters

string $name: The machine name of the context to validate.

Return value

bool

File

src/ContextManager.php, line 148

Class

ContextManager
This is the manager service for the context module and should not be confused with the built in contexts in Drupal.

Namespace

Drupal\context

Code

public function contextExists($name) {
  $entity = $this->entityQuery
    ->get('context')
    ->condition('name', $name)
    ->execute();
  return (bool) $entity;
}