FrozenParameterBag.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. class FrozenParameterBag extends ParameterBag
  18. {
  19. /**
  20. * Constructor.
  21. *
  22. * For performance reasons, the constructor assumes that
  23. * all keys are already lowercased.
  24. *
  25. * This is always the case when used internally.
  26. *
  27. * @param array $parameters An array of parameters
  28. */
  29. public function __construct(array $parameters = array())
  30. {
  31. $this->parameters = $parameters;
  32. $this->resolved = true;
  33. }
  34. /**
  35. * {@inheritdoc}
  36. */
  37. public function clear()
  38. {
  39. throw new LogicException('Impossible to call clear() on a frozen ParameterBag.');
  40. }
  41. /**
  42. * {@inheritdoc}
  43. */
  44. public function add(array $parameters)
  45. {
  46. throw new LogicException('Impossible to call add() on a frozen ParameterBag.');
  47. }
  48. /**
  49. * {@inheritdoc}
  50. */
  51. public function set($name, $value)
  52. {
  53. throw new LogicException('Impossible to call set() on a frozen ParameterBag.');
  54. }
  55. /**
  56. * {@inheritdoc}
  57. */
  58. public function remove($name)
  59. {
  60. throw new LogicException('Impossible to call remove() on a frozen ParameterBag.');
  61. }
  62. }