Skip to content

Instantly share code, notes, and snippets.

@fago
Created February 16, 2013 18:26
Show Gist options
  • Save fago/4968056 to your computer and use it in GitHub Desktop.
Save fago/4968056 to your computer and use it in GitHub Desktop.
$plugin->setContextValue()
/**
* Implements \Drupal\Component\Plugin\ContextAwarePluginInterface::setContextValue().
*/
public function setContextValue($key, $value) {
$context_definition = $this->getContextDefinition($key);
$this->context[$key] = new Context($context_definition);
$this->context[$key]->setValue($value);
if ($this->context[$key]->validate($value)->count() > 0) {
throw new PluginException("The provided value for $key is not valid.");
}
return $this;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment