Skip to content

Commit

Permalink
Validator decomposition for inheritance
Browse files Browse the repository at this point in the history
  • Loading branch information
muxx committed Jun 16, 2016
1 parent a833ba8 commit 462e28a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Validator/Constraints/TwigSandboxValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,18 @@ public function __construct(EnvironmentBuilder $builder)
$this->builder = $builder;
}

public function getTwig()
{
return $this->builder->getSandboxEnvironment();
}

public function validate($value, Constraint $constraint)
{
if (!$value) {
return;
}

$twig = $this->builder->getSandboxEnvironment();
$twig = $this->getTwig();

try {
$twig->render($value);
Expand Down

0 comments on commit 462e28a

Please sign in to comment.