ContainerParametersResource.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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\Config;
  11. use Symfony\Component\Config\Resource\ResourceInterface;
  12. /**
  13. * Tracks container parameters.
  14. *
  15. * @author Maxime Steinhausser <maxime.steinhausser@gmail.com>
  16. */
  17. class ContainerParametersResource implements ResourceInterface, \Serializable
  18. {
  19. private $parameters;
  20. /**
  21. * @param array $parameters The container parameters to track
  22. */
  23. public function __construct(array $parameters)
  24. {
  25. $this->parameters = $parameters;
  26. }
  27. /**
  28. * {@inheritdoc}
  29. */
  30. public function __toString()
  31. {
  32. return 'container_parameters_'.md5(serialize($this->parameters));
  33. }
  34. /**
  35. * {@inheritdoc}
  36. */
  37. public function serialize()
  38. {
  39. return serialize($this->parameters);
  40. }
  41. /**
  42. * {@inheritdoc}
  43. */
  44. public function unserialize($serialized)
  45. {
  46. $this->parameters = unserialize($serialized);
  47. }
  48. /**
  49. * @return array Tracked parameters
  50. */
  51. public function getParameters()
  52. {
  53. return $this->parameters;
  54. }
  55. }