ParametersConfigurator.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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\DependencyInjection\Loader\Configurator;
  11. use Symfony\Component\DependencyInjection\ContainerBuilder;
  12. /**
  13. * @author Nicolas Grekas <p@tchwork.com>
  14. */
  15. class ParametersConfigurator extends AbstractConfigurator
  16. {
  17. public const FACTORY = 'parameters';
  18. private $container;
  19. public function __construct(ContainerBuilder $container)
  20. {
  21. $this->container = $container;
  22. }
  23. /**
  24. * Creates a parameter.
  25. *
  26. * @return $this
  27. */
  28. final public function set(string $name, $value): self
  29. {
  30. $this->container->setParameter($name, static::processValue($value, true));
  31. return $this;
  32. }
  33. /**
  34. * Creates a parameter.
  35. *
  36. * @return $this
  37. */
  38. final public function __invoke(string $name, $value): self
  39. {
  40. return $this->set($name, $value);
  41. }
  42. }