ParameterBagInterface.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. * @return mixed The parameter value
  44. *
  45. * @throws ParameterNotFoundException if the parameter is not defined
  46. */
  47. public function get(string $name);
  48. /**
  49. * Removes a parameter.
  50. */
  51. public function remove(string $name);
  52. /**
  53. * Sets a service container parameter.
  54. *
  55. * @param mixed $value The parameter value
  56. *
  57. * @throws LogicException if the parameter can not be set
  58. */
  59. public function set(string $name, $value);
  60. /**
  61. * Returns true if a parameter name is defined.
  62. *
  63. * @return bool true if the parameter name is defined, false otherwise
  64. */
  65. public function has(string $name);
  66. /**
  67. * Replaces parameter placeholders (%name%) by their values for all parameters.
  68. */
  69. public function resolve();
  70. /**
  71. * Replaces parameter placeholders (%name%) by their values.
  72. *
  73. * @param mixed $value A value
  74. *
  75. * @throws ParameterNotFoundException if a placeholder references a parameter that does not exist
  76. */
  77. public function resolveValue($value);
  78. /**
  79. * Escape parameter placeholders %.
  80. *
  81. * @param mixed $value
  82. *
  83. * @return mixed
  84. */
  85. public function escapeValue($value);
  86. /**
  87. * Unescape parameter placeholders %.
  88. *
  89. * @param mixed $value
  90. *
  91. * @return mixed
  92. */
  93. public function unescapeValue($value);
  94. }