mark getAppContainer as a valid way to construct app containers

this is triggerd (and not cought by the query arm) if an item from an app is queried before the app queries it's own Application instance

Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
Robin Appelman 2019-11-04 19:32:49 +01:00
parent 13960b69da
commit 5ca27085fc
No known key found for this signature in database
GPG Key ID: 42B69D8A64526EFB
1 changed files with 8 additions and 0 deletions

View File

@ -77,6 +77,8 @@ class App {
$e = new \RuntimeException('App class ' . $applicationClassName . ' is not setup via query() but directly'); $e = new \RuntimeException('App class ' . $applicationClassName . ' is not setup via query() but directly');
$setUpViaQuery = false; $setUpViaQuery = false;
$classNameParts = explode('\\', trim($applicationClassName, '\\'));
foreach ($e->getTrace() as $step) { foreach ($e->getTrace() as $step) {
if (isset($step['class'], $step['function'], $step['args'][0]) && if (isset($step['class'], $step['function'], $step['args'][0]) &&
$step['class'] === ServerContainer::class && $step['class'] === ServerContainer::class &&
@ -84,6 +86,12 @@ class App {
$step['args'][0] === $applicationClassName) { $step['args'][0] === $applicationClassName) {
$setUpViaQuery = true; $setUpViaQuery = true;
break; break;
} else if (isset($step['class'], $step['function'], $step['args'][0]) &&
$step['class'] === ServerContainer::class &&
$step['function'] === 'getAppContainer' &&
$step['args'][1] === $classNameParts[1]) {
$setUpViaQuery = true;
break;
} }
} }