Skip to content

Instantly share code, notes, and snippets.

@fago
Created February 9, 2013 21:31
Show Gist options
  • Save fago/4747199 to your computer and use it in GitHub Desktop.
Save fago/4747199 to your computer and use it in GitHub Desktop.
executable validation
/**
* Implements \Drupal\Core\Executable\ExecutableInterface::valdidate().
*/
public function valdidate() {
$violations = new \Symfony\Component\Validator\ConstraintViolationList();
if ($definitions = $this->getContextDefinitions()) {
foreach ($definitions as $key => $definition) {
// Validate any set values.
if (isset($this->context[$key])) {
$typed_context = $this->context[$key]->getTypedContext();
$violations->addAll($typed_context->validate());
}
// @todo: If no value is set, make sure any mapping is validated.
}
}
return $violations;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment