3 namespace Drupal\Core\TypedData\Validation;
5 use Drupal\Core\Validation\TranslatorInterface;
6 use Symfony\Component\Validator\Context\ExecutionContextFactoryInterface;
7 use Symfony\Component\Validator\Validator\ValidatorInterface;
10 * Defines an execution factory for the Typed Data validator.
12 * We do not use the factory provided by Symfony as it is marked internal.
14 * @codingStandardsIgnoreStart
16 class ExecutionContextFactory implements ExecutionContextFactoryInterface {
19 * @var \Drupal\Core\Validation\TranslatorInterface
21 protected $translator;
26 protected $translationDomain;
29 * Constructs a new ExecutionContextFactory instance.
31 * @param \Drupal\Core\Validation\TranslatorInterface $translator
32 * The translator instance.
33 * @param string $translationDomain
34 * (optional) The translation domain.
36 public function __construct(TranslatorInterface $translator, $translationDomain = null)
38 $this->translator = $translator;
39 $this->translationDomain = $translationDomain;
45 public function createContext(ValidatorInterface $validator, $root)
47 return new ExecutionContext(
51 $this->translationDomain