ExecutionContextFactory.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 $translator;
  23. private $translationDomain;
  24. public function __construct(TranslatorInterface $translator, string $translationDomain = null)
  25. {
  26. $this->translator = $translator;
  27. $this->translationDomain = $translationDomain;
  28. }
  29. /**
  30. * {@inheritdoc}
  31. */
  32. public function createContext(ValidatorInterface $validator, $root)
  33. {
  34. return new ExecutionContext(
  35. $validator,
  36. $root,
  37. $this->translator,
  38. $this->translationDomain
  39. );
  40. }
  41. }