Reference.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace Symfony\Components\DependencyInjection;
  3. /*
  4. * This file is part of the Symfony framework.
  5. *
  6. * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
  7. *
  8. * This source file is subject to the MIT license that is bundled
  9. * with this source code in the file LICENSE.
  10. */
  11. /**
  12. * Reference represents a service reference.
  13. *
  14. * @package Symfony
  15. * @subpackage Components_DependencyInjection
  16. * @author Fabien Potencier <fabien.potencier@symfony-project.com>
  17. */
  18. class Reference
  19. {
  20. protected $id;
  21. protected $invalidBehavior;
  22. /**
  23. * Constructor.
  24. *
  25. * @param string $id The service identifier
  26. * @param int $invalidBehavior The behavior when the service does not exist
  27. *
  28. * @see Container
  29. */
  30. public function __construct($id, $invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE)
  31. {
  32. $this->id = $id;
  33. $this->invalidBehavior = $invalidBehavior;
  34. }
  35. /**
  36. * __toString.
  37. *
  38. * @return string The service identifier
  39. */
  40. public function __toString()
  41. {
  42. return (string) $this->id;
  43. }
  44. public function getInvalidBehavior()
  45. {
  46. return $this->invalidBehavior;
  47. }
  48. }