allow configuring the command bus

This commit is contained in:
Robin Appelman 2017-08-24 16:21:50 +02:00
parent 9731350ace
commit 5431b8bfc2
1 changed files with 41 additions and 30 deletions

View File

@ -39,6 +39,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
namespace OC;
use bantu\IniGetWrapper\IniGetWrapper;
@ -149,7 +150,6 @@ class Server extends ServerContainer implements IServerContainer {
$this->registerAlias(IActionFactory::class, ActionFactory::class);
$this->registerService(\OCP\IPreview::class, function (Server $c) {
return new PreviewManager(
$c->getConfig(),
@ -694,8 +694,19 @@ class Server extends ServerContainer implements IServerContainer {
return new IniGetWrapper();
});
$this->registerService('AsyncCommandBus', function (Server $c) {
$busClass = $c->getConfig()->getSystemValue('commandbus');
if ($busClass) {
list($app, $class) = explode('::', $busClass, 2);
if ($c->getAppManager()->isInstalled($app)) {
\OC_App::loadApp($app);
return $c->query($class);
} else {
throw new ServiceUnavailableException("The app providing the command bus ($app) is not enabled");
}
} else {
$jobList = $c->getJobList();
return new CronBus($jobList);
}
});
$this->registerService('TrustedDomainHelper', function ($c) {
return new TrustedDomainHelper($this->getConfig());