Blame view

sources/apps/contacts/lib/dispatcher.php 3.86 KB
d1bafeea1   Kload   [fix] Upgrade to ...
1
2
  <?php
  /**
6d9380f96   Cédric Dupont   Update sources OC...
3
4
5
   * @author Thomas Tanghus
   * @copyright 2013-2014 Thomas Tanghus (thomas@tanghus.net)
   *
d1bafeea1   Kload   [fix] Upgrade to ...
6
7
8
9
10
11
12
13
14
15
16
17
18
   * 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\PageController,
  	OCA\Contacts\Controller\AddressBookController,
6d9380f96   Cédric Dupont   Update sources OC...
19
  	OCA\Contacts\Controller\BackendController,
d1bafeea1   Kload   [fix] Upgrade to ...
20
21
22
23
24
25
26
27
28
29
30
31
32
33
  	OCA\Contacts\Controller\GroupController,
  	OCA\Contacts\Controller\ContactController,
  	OCA\Contacts\Controller\ContactPhotoController,
  	OCA\Contacts\Controller\SettingsController,
  	OCA\Contacts\Controller\ImportController,
  	OCA\Contacts\Controller\ExportController;
  
  /**
   * This class manages our app actions
   *
   * TODO: Merge with App
   */
  
  class Dispatcher extends MainApp {
6d9380f96   Cédric Dupont   Update sources OC...
34
35
36
37
38
  
  	/**
  	 * @var string
  	 */
  	protected $appName;
d1bafeea1   Kload   [fix] Upgrade to ...
39
  	/**
6d9380f96   Cédric Dupont   Update sources OC...
40
  	* @var \OCA\Contacts\App
d1bafeea1   Kload   [fix] Upgrade to ...
41
42
  	*/
  	protected $app;
6d9380f96   Cédric Dupont   Update sources OC...
43
44
45
46
47
48
49
50
51
  	/**
  	* @var \OCP\IServerContainer
  	*/
  	protected $server;
  
  	/**
  	* @var \OCP\AppFramework\IAppContainer
  	*/
  	protected $container;
d1bafeea1   Kload   [fix] Upgrade to ...
52
  	public function __construct($params) {
6d9380f96   Cédric Dupont   Update sources OC...
53
54
  		$this->appName = 'contacts';
  		parent::__construct($this->appName, $params);
d1bafeea1   Kload   [fix] Upgrade to ...
55
  		$this->container = $this->getContainer();
6d9380f96   Cédric Dupont   Update sources OC...
56
  		$this->server = $this->container->getServer();
d1bafeea1   Kload   [fix] Upgrade to ...
57
58
59
60
  		$this->app = new App($this->container->query('API')->getUserId());
  		$this->registerServices();
  		$this->container->registerMiddleware('HttpMiddleware');
  	}
d1bafeea1   Kload   [fix] Upgrade to ...
61
62
  	public function registerServices() {
  		$app = $this->app;
6d9380f96   Cédric Dupont   Update sources OC...
63
64
65
66
67
68
69
70
71
  		$appName = $this->appName;
  
  		$this->container->registerService('HttpMiddleware', function($container) {
  			return new HttpMiddleware();
  		});
  
  		$this->container->registerService('PageController', function(IAppContainer $container) use($app, $appName) {
  			$request = $container->query('Request');
  			return new PageController($appName, $request);
d1bafeea1   Kload   [fix] Upgrade to ...
72
  		});
6d9380f96   Cédric Dupont   Update sources OC...
73
74
75
76
  		$this->container->registerService('AddressBookController', function(IAppContainer $container) use($app, $appName) {
  			$request = $container->query('Request');
  			$api = $container->query('API');
  			return new AddressBookController($appName, $request, $app, $api);
d1bafeea1   Kload   [fix] Upgrade to ...
77
  		});
6d9380f96   Cédric Dupont   Update sources OC...
78
79
80
  		$this->container->registerService('BackendController', function(IAppContainer $container) use($app, $appName) {
  			$request = $container->query('Request');
  			return new BackendController($container, $request, $app);
d1bafeea1   Kload   [fix] Upgrade to ...
81
  		});
6d9380f96   Cédric Dupont   Update sources OC...
82
83
84
85
  		$this->container->registerService('GroupController', function(IAppContainer $container) use($app, $appName) {
  			$request = $container->query('Request');
  			$tags = $container->getServer()->getTagManager()->load('contact');
  			return new GroupController($appName, $request, $app, $tags);
d1bafeea1   Kload   [fix] Upgrade to ...
86
  		});
6d9380f96   Cédric Dupont   Update sources OC...
87
88
89
  		$this->container->registerService('ContactController', function(IAppContainer $container) use($app, $appName) {
  			$request = $container->query('Request');
  			return new ContactController($appName, $request, $app);
d1bafeea1   Kload   [fix] Upgrade to ...
90
  		});
6d9380f96   Cédric Dupont   Update sources OC...
91
92
93
94
  		$this->container->registerService('ContactPhotoController', function(IAppContainer $container) use($app, $appName) {
  			$request = $container->query('Request');
  			$cache = $container->getServer()->getCache();
  			return new ContactPhotoController($appName, $request, $app, $cache);
d1bafeea1   Kload   [fix] Upgrade to ...
95
  		});
6d9380f96   Cédric Dupont   Update sources OC...
96
97
98
  		$this->container->registerService('SettingsController', function(IAppContainer $container) use($app, $appName) {
  			$request = $container->query('Request');
  			return new SettingsController($appName, $request, $app);
d1bafeea1   Kload   [fix] Upgrade to ...
99
  		});
6d9380f96   Cédric Dupont   Update sources OC...
100
101
102
103
  		$this->container->registerService('ImportController', function(IAppContainer $container) use($app, $appName) {
  			$request = $container->query('Request');
  			$cache = $container->getServer()->getCache();
  			return new ImportController($appName, $request, $app, $cache);
d1bafeea1   Kload   [fix] Upgrade to ...
104
  		});
6d9380f96   Cédric Dupont   Update sources OC...
105
106
107
  		$this->container->registerService('ExportController', function(IAppContainer $container) use($app, $appName) {
  			$request = $container->query('Request');
  			return new ExportController($appName, $request, $app);
d1bafeea1   Kload   [fix] Upgrade to ...
108
109
110
111
  		});
  	}
  
  }