Further Drupal 8.6.4 changes. Some core files were not committed before a commit...
[yaffs-website] / web / core / lib / Drupal / Core / TypedData / Validation / ExecutionContextFactory.php
1 <?php
2
3 namespace Drupal\Core\TypedData\Validation;
4
5 use Drupal\Core\Validation\TranslatorInterface;
6 use Symfony\Component\Validator\Context\ExecutionContextFactoryInterface;
7 use Symfony\Component\Validator\Validator\ValidatorInterface;
8
9 /**
10  * Defines an execution factory for the Typed Data validator.
11  *
12  * We do not use the factory provided by Symfony as it is marked internal.
13  *
14  * @codingStandardsIgnoreStart
15  */
16 class ExecutionContextFactory implements ExecutionContextFactoryInterface {
17
18   /**
19    * @var \Drupal\Core\Validation\TranslatorInterface
20    */
21   protected $translator;
22
23   /**
24    * @var string|null
25    */
26   protected $translationDomain;
27
28   /**
29    * Constructs a new ExecutionContextFactory instance.
30    *
31    * @param \Drupal\Core\Validation\TranslatorInterface $translator
32    *   The translator instance.
33    * @param string $translationDomain
34    *   (optional) The translation domain.
35    */
36   public function __construct(TranslatorInterface $translator, $translationDomain = null)
37   {
38     $this->translator = $translator;
39     $this->translationDomain = $translationDomain;
40   }
41
42   /**
43    * {@inheritdoc}
44    */
45   public function createContext(ValidatorInterface $validator, $root)
46   {
47     return new ExecutionContext(
48       $validator,
49       $root,
50       $this->translator,
51       $this->translationDomain
52     );
53   }
54
55 }