You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

IContainer.php 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Bernhard Posselt <dev@bernhard-posselt.com>
  6. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  7. * @author Joas Schilling <coding@schilljs.com>
  8. * @author Morris Jobke <hey@morrisjobke.de>
  9. * @author Roeland Jago Douma <roeland@famdouma.nl>
  10. * @author Thomas Müller <thomas.mueller@tmit.eu>
  11. *
  12. * @license AGPL-3.0
  13. *
  14. * This code is free software: you can redistribute it and/or modify
  15. * it under the terms of the GNU Affero General Public License, version 3,
  16. * as published by the Free Software Foundation.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU Affero General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU Affero General Public License, version 3,
  24. * along with this program. If not, see <http://www.gnu.org/licenses/>
  25. *
  26. */
  27. /**
  28. * Public interface of ownCloud for apps to use.
  29. * Container interface
  30. *
  31. */
  32. // use OCP namespace for all classes that are considered public.
  33. // This means that they should be used by apps instead of the internal ownCloud classes
  34. namespace OCP;
  35. use Closure;
  36. use OCP\AppFramework\QueryException;
  37. use Psr\Container\ContainerExceptionInterface;
  38. use Psr\Container\ContainerInterface;
  39. /**
  40. * Class IContainer
  41. *
  42. * IContainer is the basic interface to be used for any internal dependency injection mechanism
  43. *
  44. * @since 6.0.0
  45. * @deprecated 20.0.0 use \Psr\Container\ContainerInterface
  46. */
  47. interface IContainer extends ContainerInterface {
  48. /**
  49. * @template T
  50. *
  51. * If a parameter is not registered in the container try to instantiate it
  52. * by using reflection to find out how to build the class
  53. * @param string $name the class name to resolve
  54. * @psalm-param string|class-string<T> $name
  55. * @return \stdClass
  56. * @psalm-return ($name is class-string ? T : mixed)
  57. * @since 8.2.0
  58. * @deprecated 20.0.0 use \Psr\Container\ContainerInterface::get
  59. * @throws ContainerExceptionInterface if the class could not be found or instantiated
  60. * @throws QueryException if the class could not be found or instantiated
  61. */
  62. public function resolve($name);
  63. /**
  64. * Look up a service for a given name in the container.
  65. *
  66. * @template T
  67. *
  68. * @param string $name
  69. * @psalm-param string|class-string<T> $name
  70. * @param bool $autoload Should we try to autoload the service. If we are trying to resolve built in types this makes no sense for example
  71. * @return mixed
  72. * @psalm-return ($name is class-string ? T : mixed)
  73. * @throws ContainerExceptionInterface if the query could not be resolved
  74. * @throws QueryException if the query could not be resolved
  75. * @since 6.0.0
  76. * @deprecated 20.0.0 use \Psr\Container\ContainerInterface::get
  77. */
  78. public function query(string $name, bool $autoload = true);
  79. /**
  80. * A value is stored in the container with it's corresponding name
  81. *
  82. * @param string $name
  83. * @param mixed $value
  84. * @return void
  85. * @since 6.0.0
  86. * @deprecated 20.0.0 use \OCP\AppFramework\Bootstrap\IRegistrationContext::registerParameter
  87. */
  88. public function registerParameter($name, $value);
  89. /**
  90. * A service is registered in the container where a closure is passed in which will actually
  91. * create the service on demand.
  92. * In case the parameter $shared is set to true (the default usage) the once created service will remain in
  93. * memory and be reused on subsequent calls.
  94. * In case the parameter is false the service will be recreated on every call.
  95. *
  96. * @param string $name
  97. * @param \Closure $closure
  98. * @param bool $shared
  99. * @return void
  100. * @since 6.0.0
  101. * @deprecated 20.0.0 use \OCP\AppFramework\Bootstrap\IRegistrationContext::registerService
  102. */
  103. public function registerService($name, Closure $closure, $shared = true);
  104. /**
  105. * Shortcut for returning a service from a service under a different key,
  106. * e.g. to tell the container to return a class when queried for an
  107. * interface
  108. * @param string $alias the alias that should be registered
  109. * @param string $target the target that should be resolved instead
  110. * @since 8.2.0
  111. * @deprecated 20.0.0 use \OCP\AppFramework\Bootstrap\IRegistrationContext::registerServiceAlias
  112. */
  113. public function registerAlias($alias, $target);
  114. }