Welcome to mirror list, hosted at ThFree Co, Russian Federation.

Application.php « AppInfo « lib - github.com/pierre-alain-b/rainloop-nextcloud.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ae8d2dc6170819d65e3b805a06faacf37171aa15 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php

namespace OCA\RainLoop\AppInfo;

use OCA\RainLoop\Util\RainLoopHelper;
use OCA\RainLoop\Controller\AjaxController;
use OCA\RainLoop\Controller\PageController;

use OCP\AppFramework\App;
use OCP\IL10N;
use OCP\IUser;

class Application extends App {

	public function __construct(array $urlParams = []) {
		parent::__construct('rainloop', $urlParams);

		$container = $this->getContainer();
		$server = $container->getServer();
		$config = $server->getConfig();

		/**
		 * Controllers
		 */
		$container->registerService(
			'PageController', function($c) {
				return new PageController(
					$c->query('AppName'),
					$c->query('Request'),
					$c->getServer()->getAppManager(),
					$c->query('ServerContainer')->getConfig(),
					$c->getServer()->getSession()
				);
			}
		);

		$container->registerService(
			'AjaxController', function($c) {
				return new AjaxController(
					$c->query('AppName'),
					$c->query('Request'),
					$c->getServer()->getAppManager(),
					$c->query('ServerContainer')->getConfig(),
					$c->query(IL10N::class)
				);
			}
		);

		/**
		 * Utils
		 */
		$container->registerService(
			'RainLoopHelper', function($c) {
				return new RainLoopHelper(
					$c->getServer()->getConfig(),
					$c->getServer()->getUserSession(),
					$c->getServer()->getAppManager(),
					$c->getServer()->getSession()
				);
			}
		);

		// Add script js/rainloop.js
		\OCP\Util::addScript('rainloop', 'rainloop');
	}

	public function registerNavigation() {
		$container = $this->getContainer();

		$container->query('OCP\INavigationManager')->add(function () use ($container) {
			$urlGenerator = $container->query('OCP\IURLGenerator');
			return [
				'id' => 'rainloop',
				'order' => 10,
				'href' => $urlGenerator->linkToRoute('rainloop.page.index'),
				'icon' => $urlGenerator->imagePath('rainloop', 'rainloop.svg'),
				'name' => \OCP\Util::getL10N('rainloop')->t('Email')
			];
		});
	}

	public function registerPersonalSettings() {
		\OCP\App::registerPersonal('rainloop', 'templates/personal');
	}

}