You are here

public function ContextManager::contextExists in Context 8.4

Same name and namespace in other branches
  1. 8 src/ContextManager.php \Drupal\context\ContextManager::contextExists()
  2. 8.0 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 TRUE on context name already exist, FALSE on context name not exist.

File

src/ContextManager.php, line 214

Class

ContextManager
This is the manager service for the context module.

Namespace

Drupal\context

Code

public function contextExists($name) {
  $entity = $this->entityTypeManager
    ->getStorage('context')
    ->loadByProperties([
    'name' => $name,
  ]);
  return (bool) $entity;
}