resolveInjection supports named injections

This commit is contained in:
Tobe O 2019-04-10 19:01:04 -04:00
parent efbb09169a
commit 47261f0a08
2 changed files with 3 additions and 0 deletions

View file

@ -4,6 +4,7 @@
* Add `Angel.environment`. * Add `Angel.environment`.
* Deprecated `app.isProduction` in favor of `app.environment.isProduction`. * Deprecated `app.isProduction` in favor of `app.environment.isProduction`.
* Allow setting of `bodyAsObject`, `bodyAsMap`, or `bodyAsList` **exactly once**. * Allow setting of `bodyAsObject`, `bodyAsMap`, or `bodyAsList` **exactly once**.
* Resolve named singletons in `resolveInjection`.
# 2.0.0-alpha.24 # 2.0.0-alpha.24
* Add `AngelEnv` class to `core`. * Add `AngelEnv` class to `core`.

View file

@ -39,6 +39,8 @@ resolveInjection(requirement, InjectionRequest injection, RequestContext req,
if (value == null && param.required != false) throw param.error; if (value == null && param.required != false) throw param.error;
return value; return value;
} else if (requirement is String) { } else if (requirement is String) {
if (req.container.hasNamed(requirement))
return req.container.findByName(requirement);
if (req.params.containsKey(requirement)) { if (req.params.containsKey(requirement)) {
return req.params[requirement]; return req.params[requirement];
} else if ((propFromApp = req.app.findProperty(requirement)) != null) } else if ((propFromApp = req.app.findProperty(requirement)) != null)