ContainerInterface.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. * ContainerInterface is the interface implemented by service container classes.
  13. *
  14. * @package Symfony
  15. * @subpackage Components_DependencyInjection
  16. * @author Fabien Potencier <fabien.potencier@symfony-project.com>
  17. */
  18. interface ContainerInterface
  19. {
  20. const EXCEPTION_ON_INVALID_REFERENCE = 1;
  21. const NULL_ON_INVALID_REFERENCE = 2;
  22. const IGNORE_ON_INVALID_REFERENCE = 3;
  23. /**
  24. * Sets a service.
  25. *
  26. * @param string $id The service identifier
  27. * @param object $service The service instance
  28. */
  29. public function set($id, $service);
  30. /**
  31. * Gets a service.
  32. *
  33. * @param string $id The service identifier
  34. * @param int $invalidBehavior The behavior when the service does not exist
  35. *
  36. * @return object The associated service
  37. *
  38. * @throws \InvalidArgumentException if the service is not defined
  39. *
  40. * @see Reference
  41. */
  42. public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE);
  43. /**
  44. * Returns true if the given service is defined.
  45. *
  46. * @param string $id The service identifier
  47. *
  48. * @return Boolean true if the service is defined, false otherwise
  49. */
  50. public function has($id);
  51. }