public function ContextAwarePluginBase::validateContexts

Implements \Drupal\Component\Plugin\ContextAwarePluginInterface::valdidateContexts().

Overrides ContextAwarePluginInterface::validateContexts

File

drupal/core/lib/Drupal/Component/Plugin/ContextAwarePluginBase.php, line 141
Contains \Drupal\Component\Plugin\ContextAwarePluginBase

Class

ContextAwarePluginBase
Base class for plugins that are context aware.

Namespace

Drupal\Component\Plugin

Code

public function validateContexts() {
  $violations = new ConstraintViolationList();

  // @todo: Implement symfony validator API to let the validator traverse
  // and set property paths accordingly.
  foreach ($this
    ->getContextDefinitions() as $name => $definition) {

    // Validate any set values.
    if (isset($this->context[$name])) {
      $violations
        ->addAll($this->context[$name]
        ->validate());
    }

    // @todo: If no value is set, make sure any mapping is validated.
  }
  return $violations;
}