From 462e28af0448a6631a51c7f63009c9bdcff0f911 Mon Sep 17 00:00:00 2001 From: Ilyas Salikhov Date: Thu, 16 Jun 2016 17:41:04 +0300 Subject: [PATCH] Validator decomposition for inheritance --- Validator/Constraints/TwigSandboxValidator.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Validator/Constraints/TwigSandboxValidator.php b/Validator/Constraints/TwigSandboxValidator.php index 89fc797..24a3b39 100644 --- a/Validator/Constraints/TwigSandboxValidator.php +++ b/Validator/Constraints/TwigSandboxValidator.php @@ -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);