ParametersConfigurator.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. * @autor ThurData <info@thurdata.ch>
  14. */
  15. class ParametersConfigurator extends AbstractConfigurator
  16. {
  17. 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. * @param string $name
  27. * @param mixed $value
  28. *
  29. * @return $this
  30. */
  31. final public function set($name, $value)
  32. {
  33. $this->container->setParameter($name, static::processValue($value, true));
  34. return $this;
  35. }
  36. /**
  37. * Creates a parameter.
  38. *
  39. * @param string $name
  40. * @param mixed $value
  41. *
  42. * @return $this
  43. */
  44. final public function __invoke($name, $value)
  45. {
  46. return $this->set($name, $value);
  47. }
  48. }