1
0
mirror of https://github.com/owncloudarchive/contacts.git synced 2025-01-25 14:52:17 +01:00
OwncloudContactsOfficial/lib/dispatcher.php

74 lines
2.7 KiB
PHP
Raw Normal View History

2013-09-17 18:46:59 +02:00
<?php
/**
* Copyright (c) 2013 Thomas Tanghus (thomas@tanghus.net)
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
namespace OCA\Contacts;
use OCP\AppFramework\App as MainApp,
OCP\AppFramework\IAppContainer,
OCA\Contacts\App,
OCA\Contacts\Middleware\Http as HttpMiddleware,
OCA\Contacts\Controller\AddressBookController,
OCA\Contacts\Controller\GroupController,
OCA\Contacts\Controller\ContactController,
OCA\Contacts\Controller\ContactPhotoController,
OCA\Contacts\Controller\SettingsController,
2013-09-24 13:39:45 +02:00
OCA\Contacts\Controller\ImportController,
OCA\Contacts\Controller\ExportController;
2013-09-17 18:46:59 +02:00
/**
* This class manages our app actions
*/
class Dispatcher extends MainApp {
/**
* @var App
*/
protected $app;
public function __construct($params) {
parent::__construct('contacts');
2013-09-17 18:46:59 +02:00
$this->container = $this->getContainer();
2013-10-01 19:13:28 +02:00
$this->container['urlParams'] = $params;
$this->container->registerMiddleware(new HttpMiddleware($this->container));
2013-09-17 18:46:59 +02:00
// TODO: Remove this once sorted out.
// When querying the middleware dispatcher Request gets instantiated
// but urlParams isn't set yet
2013-09-27 16:48:15 +02:00
//$this->container['urlParams'] = $params;
//$this->middleware = $this->container->query('MiddlewareDispatcher');
//$this->middleware->registerMiddleware(new HttpMiddleware($this->container->query('API')));
2013-09-24 13:39:45 +02:00
//$this->api = $this->container->query('API');
//$this->request = $this->container->query('Request');
$this->app = new App($this->container->query('API')->getUserId());
2013-09-17 18:46:59 +02:00
$this->registerServices();
}
public function registerServices() {
$this->container->registerService('AddressBookController', function(IAppContainer $container) {
2013-09-24 13:39:45 +02:00
return new AddressBookController($container, $this->app);
2013-09-17 18:46:59 +02:00
});
$this->container->registerService('GroupController', function(IAppContainer $container) {
2013-09-24 13:39:45 +02:00
return new GroupController($container, $this->app);
2013-09-17 18:46:59 +02:00
});
$this->container->registerService('ContactController', function(IAppContainer $container) {
2013-09-24 13:39:45 +02:00
return new ContactController($container, $this->app);
2013-09-17 18:46:59 +02:00
});
$this->container->registerService('ContactPhotoController', function(IAppContainer $container) {
2013-09-24 13:39:45 +02:00
return new ContactPhotoController($container, $this->app);
2013-09-17 18:46:59 +02:00
});
$this->container->registerService('SettingsController', function(IAppContainer $container) {
2013-09-24 13:39:45 +02:00
return new SettingsController($container, $this->app);
2013-09-17 18:46:59 +02:00
});
$this->container->registerService('ImportController', function(IAppContainer $container) {
2013-09-24 13:39:45 +02:00
return new ImportController($container, $this->app);
});
$this->container->registerService('ExportController', function(IAppContainer $container) {
return new ExportController($container, $this->app);
2013-09-17 18:46:59 +02:00
});
}
}