fix loading multiple version backends from one app
Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
parent
fd9ff581e2
commit
5209cdccdb
1 changed files with 21 additions and 10 deletions
|
@ -65,25 +65,36 @@ class Application extends App {
|
|||
|
||||
public function registerVersionBackends() {
|
||||
$server = $this->getContainer()->getServer();
|
||||
$logger = $server->getLogger();
|
||||
$appManager = $server->getAppManager();
|
||||
/** @var IVersionManager $versionManager */
|
||||
$versionManager = $this->getContainer()->getServer()->query(IVersionManager::class);
|
||||
foreach($appManager->getInstalledApps() as $app) {
|
||||
$appInfo = $appManager->getAppInfo($app);
|
||||
if (isset($appInfo['versions'])) {
|
||||
$backends = $appInfo['versions'];
|
||||
foreach($backends as $backend) {
|
||||
$class = $backend['@value'];
|
||||
$for = $backend['@attributes']['for'];
|
||||
try {
|
||||
$backendObject = $server->query($class);
|
||||
$versionManager->registerBackend($for, $backendObject);
|
||||
} catch (\Exception $e) {
|
||||
$logger->logException($e);
|
||||
if (isset($backend['@value'])) {
|
||||
$this->loadBackend($backend);
|
||||
} else {
|
||||
foreach ($backend as $singleBackend) {
|
||||
$this->loadBackend($singleBackend);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function loadBackend(array $backend) {
|
||||
$server = $this->getContainer()->getServer();
|
||||
$logger = $server->getLogger();
|
||||
/** @var IVersionManager $versionManager */
|
||||
$versionManager = $this->getContainer()->getServer()->query(IVersionManager::class);
|
||||
$class = $backend['@value'];
|
||||
$for = $backend['@attributes']['for'];
|
||||
try {
|
||||
$backendObject = $server->query($class);
|
||||
$versionManager->registerBackend($for, $backendObject);
|
||||
} catch (\Exception $e) {
|
||||
$logger->logException($e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue