icontainer.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. * @since 6.0.0
  37. */
  38. interface IContainer {
  39. /**
  40. * Look up a service for a given name in the container.
  41. *
  42. * @param string $name
  43. * @return mixed
  44. * @since 6.0.0
  45. */
  46. public function query($name);
  47. /**
  48. * A value is stored in the container with it's corresponding name
  49. *
  50. * @param string $name
  51. * @param mixed $value
  52. * @return void
  53. * @since 6.0.0
  54. */
  55. public function registerParameter($name, $value);
  56. /**
  57. * A service is registered in the container where a closure is passed in which will actually
  58. * create the service on demand.
  59. * In case the parameter $shared is set to true (the default usage) the once created service will remain in
  60. * memory and be reused on subsequent calls.
  61. * In case the parameter is false the service will be recreated on every call.
  62. *
  63. * @param string $name
  64. * @param \Closure $closure
  65. * @param bool $shared
  66. * @return void
  67. * @since 6.0.0
  68. */
  69. public function registerService($name, \Closure $closure, $shared = true);
  70. }