You are here

public function Context::addCondition in Context 8.4

Same name and namespace in other branches
  1. 8 src/Entity/Context.php \Drupal\context\Entity\Context::addCondition()
  2. 8.0 src/Entity/Context.php \Drupal\context\Entity\Context::addCondition()

Set the conditions.

Parameters

array $configuration: The configuration for the condition plugin.

Return value

string The inserted condition ID.

Overrides ContextInterface::addCondition

File

src/Entity/Context.php, line 275

Class

Context
Defines the Context entity.

Namespace

Drupal\context\Entity

Code

public function addCondition(array $configuration) {

  // Add an UUID to the condition to make sure the configuration is saved
  // since the configuration export from the conditions collection wont
  // export configuration that has not been "configured".
  $configuration['uuid'] = $this
    ->uuidGenerator()
    ->generate();
  $this
    ->getConditions()
    ->addInstanceId($configuration['id'], $configuration);
  return $configuration['id'];
}