2015-07-08 21:29:55 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* ownCloud - weather
|
|
|
|
*
|
|
|
|
* This file is licensed under the Affero General Public License version 3 or
|
|
|
|
* later. See the COPYING file.
|
|
|
|
*
|
|
|
|
* @author Loic Blot <loic.blot@unix-experience.fr>
|
|
|
|
* @copyright Loic Blot 2015
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
namespace OCA\Weather\AppInfo;
|
|
|
|
|
|
|
|
use \OCP\AppFramework\App;
|
|
|
|
use \OCP\IContainer;
|
|
|
|
|
|
|
|
use \OCA\Weather\Controller\CityController;
|
2015-07-18 13:58:51 +00:00
|
|
|
use \OCA\Weather\Controller\SettingsController;
|
2015-07-11 15:01:30 +00:00
|
|
|
use \OCA\Weather\Controller\WeatherController;
|
2015-07-08 21:29:55 +00:00
|
|
|
|
|
|
|
use \OCA\Weather\Db\CityMapper;
|
2015-07-18 13:58:51 +00:00
|
|
|
use \OCA\Weather\Db\SettingsMapper;
|
2015-07-08 21:29:55 +00:00
|
|
|
|
|
|
|
class Application extends App {
|
|
|
|
|
|
|
|
public function __construct (array $urlParams=array()) {
|
|
|
|
parent::__construct('weather', $urlParams);
|
|
|
|
|
|
|
|
$container = $this->getContainer();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Core
|
|
|
|
*/
|
|
|
|
$container->registerService('UserId', function(IContainer $c) {
|
2019-04-30 13:26:55 +00:00
|
|
|
return \OC::$server->getUserSession()->getUser()->getUID();
|
2015-07-08 21:29:55 +00:00
|
|
|
});
|
|
|
|
|
2017-07-03 21:12:50 +00:00
|
|
|
$container->registerService('Config', function($c) {
|
|
|
|
return $c->query('ServerContainer')->getConfig();
|
|
|
|
});
|
|
|
|
|
2015-07-08 21:29:55 +00:00
|
|
|
/**
|
|
|
|
* Database Layer
|
|
|
|
*/
|
|
|
|
$container->registerService('CityMapper', function(IContainer $c) {
|
2017-05-23 06:44:54 +00:00
|
|
|
return new CityMapper($c->query('ServerContainer')->getDatabaseConnection());
|
2015-07-08 21:29:55 +00:00
|
|
|
});
|
|
|
|
|
2015-07-18 13:58:51 +00:00
|
|
|
$container->registerService('SettingsMapper', function(IContainer $c) {
|
2017-05-23 06:44:54 +00:00
|
|
|
return new SettingsMapper($c->query('ServerContainer')->getDatabaseConnection());
|
2015-07-18 13:58:51 +00:00
|
|
|
});
|
|
|
|
|
2015-07-08 21:29:55 +00:00
|
|
|
/**
|
|
|
|
* Controllers
|
|
|
|
*/
|
|
|
|
$container->registerService('CityController', function(IContainer $c) {
|
|
|
|
return new CityController(
|
|
|
|
$c->query('AppName'),
|
2017-07-03 21:12:50 +00:00
|
|
|
$c->query('Config'),
|
2015-07-08 21:29:55 +00:00
|
|
|
$c->query('Request'),
|
|
|
|
$c->query('UserId'),
|
2015-07-18 13:58:51 +00:00
|
|
|
$c->query('CityMapper'),
|
|
|
|
$c->query('SettingsMapper')
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
$container->registerService('SettingsController', function(IContainer $c) {
|
|
|
|
return new SettingsController(
|
|
|
|
$c->query('AppName'),
|
2017-07-03 21:12:50 +00:00
|
|
|
$c->query('Config'),
|
2015-07-18 13:58:51 +00:00
|
|
|
$c->query('Request'),
|
|
|
|
$c->query('UserId'),
|
|
|
|
$c->query('SettingsMapper'),
|
2015-07-08 21:29:55 +00:00
|
|
|
$c->query('CityMapper')
|
|
|
|
);
|
|
|
|
});
|
2015-07-11 15:01:30 +00:00
|
|
|
|
|
|
|
$container->registerService('WeatherController', function(IContainer $c) {
|
|
|
|
return new WeatherController(
|
|
|
|
$c->query('AppName'),
|
2017-07-03 21:12:50 +00:00
|
|
|
$c->query('Config'),
|
2015-07-11 15:01:30 +00:00
|
|
|
$c->query('Request'),
|
|
|
|
$c->query('UserId'),
|
2015-10-25 09:57:07 +00:00
|
|
|
$c->query('CityMapper'),
|
|
|
|
$c->query('SettingsMapper')
|
2015-07-11 15:01:30 +00:00
|
|
|
);
|
|
|
|
});
|
2015-07-08 21:29:55 +00:00
|
|
|
}
|
|
|
|
}
|