vendor/symfony/validator/Context/ExecutionContextFactory.php line 29

  1. <?php
  2. /*
  3.  * This file is part of the Symfony package.
  4.  *
  5.  * (c) Fabien Potencier <fabien@symfony.com>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace Symfony\Component\Validator\Context;
  11. use Symfony\Component\Validator\Validator\ValidatorInterface;
  12. use Symfony\Contracts\Translation\TranslatorInterface;
  13. /**
  14.  * Creates new {@link ExecutionContext} instances.
  15.  *
  16.  * @author Bernhard Schussek <bschussek@gmail.com>
  17.  *
  18.  * @internal version 2.5. Code against ExecutionContextFactoryInterface instead.
  19.  */
  20. class ExecutionContextFactory implements ExecutionContextFactoryInterface
  21. {
  22.     private TranslatorInterface $translator;
  23.     private ?string $translationDomain;
  24.     public function __construct(TranslatorInterface $translatorstring $translationDomain null)
  25.     {
  26.         $this->translator $translator;
  27.         $this->translationDomain $translationDomain;
  28.     }
  29.     public function createContext(ValidatorInterface $validatormixed $root): ExecutionContextInterface
  30.     {
  31.         return new ExecutionContext(
  32.             $validator,
  33.             $root,
  34.             $this->translator,
  35.             $this->translationDomain
  36.         );
  37.     }
  38. }