diff options
author | Joas Schilling <coding@schilljs.com> | 2016-09-20 13:26:06 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2016-09-20 13:26:06 +0200 |
commit | d9063b6141bd4c1c6754ac749427b8bc2711d2f6 (patch) | |
tree | 7310e016e07d0e17fc2138b01f15a6e7799dd595 /lib | |
parent | 1944d9b3abb5f3f20fa5e2ba2004dbd7994bb13f (diff) | |
download | nextcloud-server-d9063b6141bd4c1c6754ac749427b8bc2711d2f6.tar.gz nextcloud-server-d9063b6141bd4c1c6754ac749427b8bc2711d2f6.zip |
Use default value instead of throwing when the service could not be found
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/AppFramework/Utility/SimpleContainer.php | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/private/AppFramework/Utility/SimpleContainer.php b/lib/private/AppFramework/Utility/SimpleContainer.php index 5f637518f4d..60496ca329e 100644 --- a/lib/private/AppFramework/Utility/SimpleContainer.php +++ b/lib/private/AppFramework/Utility/SimpleContainer.php @@ -62,7 +62,16 @@ class SimpleContainer extends Container implements IContainer { $resolveName = $parameterClass->name; } - $parameters[] = $this->query($resolveName); + try { + $parameters[] = $this->query($resolveName); + } catch (\Exception $e) { + // Service not found, use the default value when available + if ($parameter->isDefaultValueAvailable()) { + $parameters[] = $parameter->getDefaultValue(); + } else { + throw $e; + } + } } return $class->newInstanceArgs($parameters); } |