Drupal investigation

ExecutionContextFactory.php 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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\Translation\TranslatorInterface;
  12. use Symfony\Component\Validator\Validator\ValidatorInterface;
  13. /**
  14. * Creates new {@link ExecutionContext} instances.
  15. *
  16. * @author Bernhard Schussek <bschussek@gmail.com>
  17. *
  18. * @internal You should not instantiate or use this class. Code against
  19. * {@link ExecutionContextFactoryInterface} instead.
  20. */
  21. class ExecutionContextFactory implements ExecutionContextFactoryInterface
  22. {
  23. /**
  24. * @var TranslatorInterface
  25. */
  26. private $translator;
  27. /**
  28. * @var string|null
  29. */
  30. private $translationDomain;
  31. /**
  32. * Creates a new context factory.
  33. *
  34. * @param TranslatorInterface $translator The translator
  35. * @param string|null $translationDomain The translation domain to
  36. * use for translating
  37. * violation messages
  38. */
  39. public function __construct(TranslatorInterface $translator, $translationDomain = null)
  40. {
  41. $this->translator = $translator;
  42. $this->translationDomain = $translationDomain;
  43. }
  44. /**
  45. * {@inheritdoc}
  46. */
  47. public function createContext(ValidatorInterface $validator, $root)
  48. {
  49. return new ExecutionContext(
  50. $validator,
  51. $root,
  52. $this->translator,
  53. $this->translationDomain
  54. );
  55. }
  56. }