FrozenParameterBag.php 1.6 KB

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