You are here

public function Context::getConstraints in Plug 7

Gets a list of validation constraints.

Return value

array Array of constraints, each being an instance of \Symfony\Component\Validator\Constraint.

Overrides ContextInterface::getConstraints

1 call to Context::getConstraints()
Context::validate in lib/Drupal/Component/Plugin/Context/Context.php
Validates the set context value.

File

lib/Drupal/Component/Plugin/Context/Context.php, line 83
Contains \Drupal\Component\Plugin\Context\Context.

Class

Context
A generic context class for wrapping data a plugin needs to operate.

Namespace

Drupal\Component\Plugin\Context

Code

public function getConstraints() {
  if (empty($this->contextDefinition['class'])) {
    throw new ContextException("An error was encountered while trying to validate the context.");
  }
  return array(
    new Type($this->contextDefinition['class']),
  );
}