summaryrefslogtreecommitdiffstats
path: root/apps/updatenotification/lib
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2018-01-11 11:38:26 +0100
committerJoas Schilling <coding@schilljs.com>2018-01-15 09:55:03 +0100
commit50e1cee5c7a8e9354e2bafac22a60b0e369a720f (patch)
tree83adf4259ecc27abdf6265dce28d8f057e98eb3f /apps/updatenotification/lib
parentffb3a3e33a2b0468a39ab9f11cf8f63f020bd0bb (diff)
downloadnextcloud-server-50e1cee5c7a8e9354e2bafac22a60b0e369a720f.tar.gz
nextcloud-server-50e1cee5c7a8e9354e2bafac22a60b0e369a720f.zip
Automatic DI for Controllers also works
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps/updatenotification/lib')
-rw-r--r--apps/updatenotification/lib/AppInfo/Application.php48
-rw-r--r--apps/updatenotification/lib/Controller/AdminController.php19
2 files changed, 18 insertions, 49 deletions
diff --git a/apps/updatenotification/lib/AppInfo/Application.php b/apps/updatenotification/lib/AppInfo/Application.php
index 5eba176f312..49b046c6fef 100644
--- a/apps/updatenotification/lib/AppInfo/Application.php
+++ b/apps/updatenotification/lib/AppInfo/Application.php
@@ -1,56 +1,32 @@
<?php
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
+ * @copyright Copyright (c) 2018, Joas Schilling <coding@schilljs.com>
*
- * @author Lukas Reschke <lukas@statuscode.ch>
- * @author Thomas Müller <thomas.mueller@tmit.eu>
+ * @author Joas Schilling <coding@schilljs.com>
*
- * @license AGPL-3.0
+ * @license GNU AGPL version 3 or any later version
*
- * 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 free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
*
* 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
+ * 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/>
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\UpdateNotification\AppInfo;
-use OC\AppFramework\Utility\TimeFactory;
-use OCA\UpdateNotification\Controller\AdminController;
-use OCA\UpdateNotification\UpdateChecker;
use OCP\AppFramework\App;
-use OCP\AppFramework\IAppContainer;
class Application extends App {
- public function __construct (array $urlParams = array()) {
- parent::__construct('updatenotification', $urlParams);
- $container = $this->getContainer();
-
- $container->registerService('AdminController', function(IAppContainer $c) {
- $updater = new \OC\Updater\VersionCheck(
- \OC::$server->getHTTPClientService(),
- \OC::$server->getConfig()
- );
- return new AdminController(
- $c->query('AppName'),
- $c->query('Request'),
- $c->getServer()->getJobList(),
- $c->getServer()->getSecureRandom(),
- $c->getServer()->getConfig(),
- new TimeFactory(),
- $c->getServer()->getL10N($c->query('AppName')),
- new UpdateChecker($updater),
- $c->getServer()->getDateTimeFormatter()
- );
- });
+ public function __construct() {
+ parent::__construct('updatenotification', []);
}
-
}
diff --git a/apps/updatenotification/lib/Controller/AdminController.php b/apps/updatenotification/lib/Controller/AdminController.php
index 9d2a5074a4a..78f2d411bb8 100644
--- a/apps/updatenotification/lib/Controller/AdminController.php
+++ b/apps/updatenotification/lib/Controller/AdminController.php
@@ -25,6 +25,7 @@
namespace OCA\UpdateNotification\Controller;
+use OCA\UpdateNotification\ResetTokenBackgroundJob;
use OCA\UpdateNotification\UpdateChecker;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\DataResponse;
@@ -37,6 +38,7 @@ use OCP\IL10N;
use OCP\IRequest;
use OCP\Security\ISecureRandom;
use OCP\Settings\ISettings;
+use OCP\Util;
class AdminController extends Controller implements ISettings {
/** @var IJobList */
@@ -87,7 +89,7 @@ class AdminController extends Controller implements ISettings {
/**
* @return TemplateResponse
*/
- public function displayPanel() {
+ public function getForm() {
$lastUpdateCheckTimestamp = $this->config->getAppValue('core', 'lastupdatedat');
$lastUpdateCheck = $this->dateTimeFormatter->formatDateTime($lastUpdateCheckTimestamp);
@@ -97,7 +99,7 @@ class AdminController extends Controller implements ISettings {
'stable',
'production',
];
- $currentChannel = \OCP\Util::getChannel();
+ $currentChannel = Util::getChannel();
// Remove the currently used channel from the channels list
if(($key = array_search($currentChannel, $channels)) !== false) {
@@ -128,13 +130,11 @@ class AdminController extends Controller implements ISettings {
}
/**
- * @UseSession
- *
* @param string $channel
* @return DataResponse
*/
public function setChannel($channel) {
- \OCP\Util::setChannel($channel);
+ Util::setChannel($channel);
$this->config->setAppValue('core', 'lastupdatedat', 0);
return new DataResponse(['status' => 'success', 'data' => ['message' => $this->l10n->t('Channel updated')]]);
}
@@ -144,7 +144,7 @@ class AdminController extends Controller implements ISettings {
*/
public function createCredentials() {
// Create a new job and store the creation date
- $this->jobList->add('OCA\UpdateNotification\ResetTokenBackgroundJob');
+ $this->jobList->add(ResetTokenBackgroundJob::class);
$this->config->setAppValue('core', 'updater.secret.created', $this->timeFactory->getTime());
// Create a new token
@@ -155,13 +155,6 @@ class AdminController extends Controller implements ISettings {
}
/**
- * @return TemplateResponse returns the instance with all parameters set, ready to be rendered
- */
- public function getForm() {
- return $this->displayPanel();
- }
-
- /**
* @return string the section ID, e.g. 'sharing'
*/
public function getSection() {