ParameterBagInterface.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. use Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException;
  13. /**
  14. * ParameterBagInterface is the interface implemented by objects that manage service container parameters.
  15. *
  16. * @author Fabien Potencier <fabien@symfony.com>
  17. */
  18. interface ParameterBagInterface
  19. {
  20. /**
  21. * Clears all parameters.
  22. *
  23. * @throws LogicException if the ParameterBagInterface can not be cleared
  24. */
  25. public function clear();
  26. /**
  27. * Adds parameters to the service container parameters.
  28. *
  29. * @param array $parameters An array of parameters
  30. *
  31. * @throws LogicException if the parameter can not be added
  32. */
  33. public function add(array $parameters);
  34. /**
  35. * Gets the service container parameters.
  36. *
  37. * @return array An array of parameters
  38. */
  39. public function all();
  40. /**
  41. * Gets a service container parameter.
  42. *
  43. * @param string $name The parameter name
  44. *
  45. * @return mixed The parameter value
  46. *
  47. * @throws ParameterNotFoundException if the parameter is not defined
  48. */
  49. public function get($name);
  50. /**
  51. * Removes a parameter.
  52. *
  53. * @param string $name The parameter name
  54. */
  55. public function remove($name);
  56. /**
  57. * Sets a service container parameter.
  58. *
  59. * @param string $name The parameter name
  60. * @param mixed $value The parameter value
  61. *
  62. * @throws LogicException if the parameter can not be set
  63. */
  64. public function set($name, $value);
  65. /**
  66. * Returns true if a parameter name is defined.
  67. *
  68. * @param string $name The parameter name
  69. *
  70. * @return bool true if the parameter name is defined, false otherwise
  71. */
  72. public function has($name);
  73. /**
  74. * Replaces parameter placeholders (%name%) by their values for all parameters.
  75. */
  76. public function resolve();
  77. /**
  78. * Replaces parameter placeholders (%name%) by their values.
  79. *
  80. * @param mixed $value A value
  81. *
  82. * @throws ParameterNotFoundException if a placeholder references a parameter that does not exist
  83. */
  84. public function resolveValue($value);
  85. /**
  86. * Escape parameter placeholders %.
  87. *
  88. * @param mixed $value
  89. *
  90. * @return mixed
  91. */
  92. public function escapeValue($value);
  93. /**
  94. * Unescape parameter placeholders %.
  95. *
  96. * @param mixed $value
  97. *
  98. * @return mixed
  99. */
  100. public function unescapeValue($value);
  101. }