icontainer.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /**
  3. * @author Morris Jobke <hey@morrisjobke.de>
  4. * @author Thomas Müller <thomas.mueller@tmit.eu>
  5. *
  6. * @copyright Copyright (c) 2015, ownCloud, Inc.
  7. * @license AGPL-3.0
  8. *
  9. * This code is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU Affero General Public License, version 3,
  11. * as published by the Free Software Foundation.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU Affero General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public License, version 3,
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>
  20. *
  21. */
  22. /**
  23. * Public interface of ownCloud for apps to use.
  24. * Container interface
  25. *
  26. */
  27. // use OCP namespace for all classes that are considered public.
  28. // This means that they should be used by apps instead of the internal ownCloud classes
  29. namespace OCP;
  30. /**
  31. * Class IContainer
  32. *
  33. * IContainer is the basic interface to be used for any internal dependency injection mechanism
  34. *
  35. * @package OCP
  36. */
  37. interface IContainer {
  38. /**
  39. * Look up a service for a given name in the container.
  40. *
  41. * @param string $name
  42. * @return mixed
  43. */
  44. function query($name);
  45. /**
  46. * A value is stored in the container with it's corresponding name
  47. *
  48. * @param string $name
  49. * @param mixed $value
  50. * @return void
  51. */
  52. function registerParameter($name, $value);
  53. /**
  54. * A service is registered in the container where a closure is passed in which will actually
  55. * create the service on demand.
  56. * In case the parameter $shared is set to true (the default usage) the once created service will remain in
  57. * memory and be reused on subsequent calls.
  58. * In case the parameter is false the service will be recreated on every call.
  59. *
  60. * @param string $name
  61. * @param \Closure $closure
  62. * @param bool $shared
  63. * @return void
  64. */
  65. function registerService($name, \Closure $closure, $shared = true);
  66. }