diff options
author | Joas Schilling <nickvergessen@owncloud.com> | 2015-12-17 14:11:51 +0300 |
---|---|---|
committer | Joas Schilling <nickvergessen@owncloud.com> | 2015-12-17 14:11:51 +0300 |
commit | 7a7c66a80537391bafebcc650a10f348cdbe9bb0 (patch) | |
tree | a8bdf25b2c3e5090463aad0f37689c5b9b83e28d /appinfo | |
parent | 9f981671f37327aac03e21633fc7257765ebe4fa (diff) |
Send request to the survey server
Diffstat (limited to 'appinfo')
-rw-r--r-- | appinfo/application.php | 60 | ||||
-rw-r--r-- | appinfo/routes.php | 30 |
2 files changed, 90 insertions, 0 deletions
diff --git a/appinfo/application.php b/appinfo/application.php new file mode 100644 index 0000000..01fa55b --- /dev/null +++ b/appinfo/application.php @@ -0,0 +1,60 @@ +<?php +/** + * @author Joas Schilling <nickvergessen@owncloud.com> + * + * @copyright Copyright (c) 2015, ownCloud, Inc. + * @license AGPL-3.0 + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License, version 3, + * along with this program. If not, see <http://www.gnu.org/licenses/> + * + */ + +namespace OCA\PopularityContestClient\AppInfo; + +use OCA\PopularityContestClient\Controller\EndpointController; +use OCA\PopularityContestClient\Collector; +use OCP\AppFramework\App; +use OCP\IContainer; + +class Application extends App { + public function __construct (array $urlParams = array()) { + parent::__construct('popularitycontestclient', $urlParams); + $container = $this->getContainer(); + + $container->registerService('EndpointController', function(IContainer $c) { + /** @var \OC\Server $server */ + $server = $c->query('ServerContainer'); + + return new EndpointController( + $c->query('AppName'), + $server->getRequest(), + $c->query('OCA\PopularityContestClient\Collector'), + $server->getHTTPClientService() + ); + }); + + $container->registerService('OCA\PopularityContestClient\Collector', function(IContainer $c) { + /** @var \OCP\IServerContainer $server */ + $server = $c->query('ServerContainer'); + + return new Collector( + $server->getConfig(), + $server->getDatabaseConnection(), + $server->getIniWrapper(), + $server->getL10NFactory()->get('popularitycontestclient') + ); + }); + + $container->registerCapability('Capabilities'); + } +} diff --git a/appinfo/routes.php b/appinfo/routes.php new file mode 100644 index 0000000..498e6d9 --- /dev/null +++ b/appinfo/routes.php @@ -0,0 +1,30 @@ +<?php +/** + * @author Joas Schilling <nickvergessen@owncloud.com> + * + * @copyright Copyright (c) 2015, ownCloud, Inc. + * @license AGPL-3.0 + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License, version 3, + * along with this program. If not, see <http://www.gnu.org/licenses/> + * + */ + +$application = new \OCA\PopularityContestClient\AppInfo\Application(); + +\OCP\API::register( + 'post', + '/apps/popularitycontestclient/api/v1/report', + [$application->getContainer()->query('EndpointController'), 'sendReport'], + 'popularitycontestclient', + \OCP\API::ADMIN_AUTH +); |