84c5a9c8cb8b821036b68a1f8ce72afc0a49a0c4
[yaffs-website] / vendor / symfony / validator / Context / ExecutionContextFactory.php
1 <?php
2
3 /*
4  * This file is part of the Symfony package.
5  *
6  * (c) Fabien Potencier <fabien@symfony.com>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11
12 namespace Symfony\Component\Validator\Context;
13
14 use Symfony\Component\Translation\TranslatorInterface;
15 use Symfony\Component\Validator\Validator\ValidatorInterface;
16
17 /**
18  * Creates new {@link ExecutionContext} instances.
19  *
20  * @author Bernhard Schussek <bschussek@gmail.com>
21  *
22  * @internal version 2.5. Code against ExecutionContextFactoryInterface instead.
23  */
24 class ExecutionContextFactory implements ExecutionContextFactoryInterface
25 {
26     private $translator;
27     private $translationDomain;
28
29     /**
30      * Creates a new context factory.
31      *
32      * @param TranslatorInterface $translator        The translator
33      * @param string|null         $translationDomain The translation domain to
34      *                                               use for translating
35      *                                               violation messages
36      */
37     public function __construct(TranslatorInterface $translator, $translationDomain = null)
38     {
39         $this->translator = $translator;
40         $this->translationDomain = $translationDomain;
41     }
42
43     /**
44      * {@inheritdoc}
45      */
46     public function createContext(ValidatorInterface $validator, $root)
47     {
48         return new ExecutionContext(
49             $validator,
50             $root,
51             $this->translator,
52             $this->translationDomain
53         );
54     }
55 }