Skip to content

Instantly share code, notes, and snippets.

@timplunkett
Forked from EclipseGc/testing.php
Last active August 29, 2015 14:02
Show Gist options
  • Save timplunkett/80b49d5ba53cdb0593c0 to your computer and use it in GitHub Desktop.
Save timplunkett/80b49d5ba53cdb0593c0 to your computer and use it in GitHub Desktop.
<?php
/**
* Constructs a new context definition object.
*
* @param array $values
* An associative array with the following keys:
* - value: The required data type.
* - required: (optional) Whether the context definition is required.
* - multiple: (optional) Whether the context definition is multivalue.
* - label: (optional) The UI label of this context definition.
* - description: (optional) The UI description of this context definition.
* - class: (optional) A custom ContextDefinitionInterface class.
*/
public function __construct(array $values) {
$values += array(
'required' => TRUE,
'multiple' => FALSE,
'label' => NULL,
'description' => NULL,
'class' => 'Drupal\Core\Plugin\Context\ContextDefinition',
);
$class = $values['class'];
$this->definition = new $class($values['value'], $values['required'], $values['multiple'], $values['label'], $values['description']);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment