diff options
author | Morris Jobke <hey@morrisjobke.de> | 2020-07-22 20:38:50 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-22 20:38:50 +0200 |
commit | 346f647962e00b1f5e5f19a8526c88a09ebca59e (patch) | |
tree | 64f324cb5ff04f29247bf00f32e84bc7c8f4ed36 /lib | |
parent | c842678f0a1fb65981a03302895192ddc58479c9 (diff) | |
parent | 7870ca06637453f4e72dbd67edbfb3603d813196 (diff) | |
download | nextcloud-server-346f647962e00b1f5e5f19a8526c88a09ebca59e.tar.gz nextcloud-server-346f647962e00b1f5e5f19a8526c88a09ebca59e.zip |
Merge pull request #21870 from nextcloud/fix/bootstrap-context-container-interfaces
Make the bootstrap context return ContainerInterface instances
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/AppFramework/Bootstrap/BootContext.php | 2 | ||||
-rw-r--r-- | lib/private/AppFramework/Bootstrap/FunctionInjector.php | 10 | ||||
-rw-r--r-- | lib/public/AppFramework/Bootstrap/IBootContext.php | 3 |
3 files changed, 7 insertions, 8 deletions
diff --git a/lib/private/AppFramework/Bootstrap/BootContext.php b/lib/private/AppFramework/Bootstrap/BootContext.php index d206884c0b7..45aaf167e75 100644 --- a/lib/private/AppFramework/Bootstrap/BootContext.php +++ b/lib/private/AppFramework/Bootstrap/BootContext.php @@ -43,7 +43,7 @@ class BootContext implements IBootContext { } public function getServerContainer(): IServerContainer { - return $this->appContainer->getServer(); + return $this->appContainer->get(IServerContainer::class); } public function injectFn(callable $fn) { diff --git a/lib/private/AppFramework/Bootstrap/FunctionInjector.php b/lib/private/AppFramework/Bootstrap/FunctionInjector.php index cb1dc7d3f37..25c1fbc0be6 100644 --- a/lib/private/AppFramework/Bootstrap/FunctionInjector.php +++ b/lib/private/AppFramework/Bootstrap/FunctionInjector.php @@ -27,17 +27,17 @@ namespace OC\AppFramework\Bootstrap; use Closure; use OCP\AppFramework\QueryException; -use OCP\IContainer; +use Psr\Container\ContainerInterface; use ReflectionFunction; use ReflectionParameter; use function array_map; class FunctionInjector { - /** @var IContainer */ + /** @var ContainerInterface */ private $container; - public function __construct(IContainer $container) { + public function __construct(ContainerInterface $container) { $this->container = $container; } @@ -47,14 +47,14 @@ class FunctionInjector { // First we try by type (more likely these days) if (($type = $param->getType()) !== null) { try { - return $this->container->query($type->getName()); + return $this->container->get($type->getName()); } catch (QueryException $ex) { // Ignore and try name as well } } // Second we try by name (mostly for primitives) try { - return $this->container->query($param->getName()); + return $this->container->get($param->getName()); } catch (QueryException $ex) { // As a last resort we pass `null` if allowed if ($type !== null && $type->allowsNull()) { diff --git a/lib/public/AppFramework/Bootstrap/IBootContext.php b/lib/public/AppFramework/Bootstrap/IBootContext.php index ee0bef6a5fa..80a4edf1cd6 100644 --- a/lib/public/AppFramework/Bootstrap/IBootContext.php +++ b/lib/public/AppFramework/Bootstrap/IBootContext.php @@ -28,7 +28,6 @@ namespace OCP\AppFramework\Bootstrap; use OCP\AppFramework\IAppContainer; use OCP\IServerContainer; use Psr\Container\ContainerExceptionInterface; -use Psr\Container\ContainerInterface; use Throwable; /** @@ -41,7 +40,7 @@ interface IBootContext { * * Useful to register and query app-specific services * - * @return IAppContainer|ContainerInterface + * @return IAppContainer * @since 20.0.0 */ public function getAppContainer(): IAppContainer; |