if (isset($values[$key]) &&
$values[$key] instanceof Translation
) { $values[$key] =
(string) $values[$key]->
get();
} else { $values[$key] = NULL;
} } if (isset($values['class'
]) && !
in_array('Drupal\Core\Plugin\Context\ContextDefinitionInterface',
class_implements($values['class'
]))) { throw new \
Exception('ContextDefinition class must implement \Drupal\Core\Plugin\Context\ContextDefinitionInterface.'
);
} $class =
$this->
getDefinitionClass($values);
$this->definition =
new $class($values['value'
],
$values['label'
],
$values['required'
],
$values['multiple'
],
$values['description'
],
$values['default_value'
]);
if (isset($values['constraints'
])) { foreach ($values['constraints'
] as $constraint_name =>
$options) { $this->definition->
addConstraint($constraint_name,
$options);
} } } /**
* Determines the context definition class to use.
*
* If the annotation specifies a specific context definition class, we use
* that. Otherwise, we use \Drupal\Core\Plugin\Context\EntityContextDefinition
* if the data type starts with 'entity:', since it contains specialized logic
* specific to entities. Otherwise, we fall back to the generic
* \Drupal\Core\Plugin\Context\ContextDefinition class.
*
* @param array $values
* The annotation values.
*
* @return string
* The fully-qualified name of the context definition class.
*/