Version 1
[yaffs-website] / vendor / symfony / validator / Context / LegacyExecutionContextFactory.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 @trigger_error('The '.__NAMESPACE__.'\LegacyExecutionContextFactory class is deprecated since version 2.5 and will be removed in 3.0.', E_USER_DEPRECATED);
15
16 use Symfony\Component\Translation\TranslatorInterface;
17 use Symfony\Component\Validator\MetadataFactoryInterface;
18 use Symfony\Component\Validator\Validator\ValidatorInterface;
19
20 /**
21  * Creates new {@link LegacyExecutionContext} instances.
22  *
23  * Implemented for backward compatibility with Symfony < 2.5.
24  *
25  * @author Bernhard Schussek <bschussek@gmail.com>
26  *
27  * @deprecated since version 2.5, to be removed in 3.0.
28  */
29 class LegacyExecutionContextFactory implements ExecutionContextFactoryInterface
30 {
31     /**
32      * @var MetadataFactoryInterface
33      */
34     private $metadataFactory;
35
36     /**
37      * @var TranslatorInterface
38      */
39     private $translator;
40
41     /**
42      * @var string|null
43      */
44     private $translationDomain;
45
46     /**
47      * Creates a new context factory.
48      *
49      * @param MetadataFactoryInterface $metadataFactory   The metadata factory
50      * @param TranslatorInterface      $translator        The translator
51      * @param string|null              $translationDomain The translation domain
52      *                                                    to use for translating
53      *                                                    violation messages
54      */
55     public function __construct(MetadataFactoryInterface $metadataFactory, TranslatorInterface $translator, $translationDomain = null)
56     {
57         $this->metadataFactory = $metadataFactory;
58         $this->translator = $translator;
59         $this->translationDomain = $translationDomain;
60     }
61
62     /**
63      * {@inheritdoc}
64      */
65     public function createContext(ValidatorInterface $validator, $root)
66     {
67         return new LegacyExecutionContext(
68             $validator,
69             $root,
70             $this->metadataFactory,
71             $this->translator,
72             $this->translationDomain
73         );
74     }
75 }