FrozenParameterBag.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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\ParameterBag;
  11. use Symfony\Component\DependencyInjection\Exception\LogicException;
  12. /**
  13. * Holds read-only parameters.
  14. *
  15. * @author Fabien Potencier <fabien@symfony.com>
  16. *
  17. * @api
  18. */
  19. class FrozenParameterBag extends ParameterBag
  20. {
  21. /**
  22. * Constructor.
  23. *
  24. * For performance reasons, the constructor assumes that
  25. * all keys are already lowercased.
  26. *
  27. * This is always the case when used internally.
  28. *
  29. * @param array $parameters An array of parameters
  30. *
  31. * @api
  32. */
  33. public function __construct(array $parameters = array())
  34. {
  35. $this->parameters = $parameters;
  36. $this->resolved = true;
  37. }
  38. /**
  39. * {@inheritDoc}
  40. *
  41. * @api
  42. */
  43. public function clear()
  44. {
  45. throw new LogicException('Impossible to call clear() on a frozen ParameterBag.');
  46. }
  47. /**
  48. * {@inheritDoc}
  49. *
  50. * @api
  51. */
  52. public function add(array $parameters)
  53. {
  54. throw new LogicException('Impossible to call add() on a frozen ParameterBag.');
  55. }
  56. /**
  57. * {@inheritDoc}
  58. *
  59. * @api
  60. */
  61. public function set($name, $value)
  62. {
  63. throw new LogicException('Impossible to call set() on a frozen ParameterBag.');
  64. }
  65. }