diff options
author | Julius Haertl <jus@bitgrid.net> | 2016-09-04 17:33:37 +0300 |
---|---|---|
committer | Julius Haertl <jus@bitgrid.net> | 2016-09-04 17:37:25 +0300 |
commit | b2cef929bc7be1f0e7a3a88ac4d73012dc8cb029 (patch) | |
tree | 2e7af8d5d5d3f6123773d22ecab86c7f7b9e3b1a /lib | |
parent | 5eb2388842c729a2e311807deec2e67b826d1a6d (diff) |
Fix unit tests
Diffstat (limited to 'lib')
-rw-r--r-- | lib/AppInfo/Application.php | 21 | ||||
-rw-r--r-- | lib/Controller/AppController.php | 15 | ||||
-rw-r--r-- | lib/Controller/SettingsController.php | 4 | ||||
-rw-r--r-- | lib/Util.php | 3 |
4 files changed, 36 insertions, 7 deletions
diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 5b426cd..275a5df 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -1,4 +1,25 @@ <?php +/** + * @copyright Copyright (c) 2016 Julius Härtl <jus@bitgrid.net> + * + * @author Julius Härtl <jus@bitgrid.net> + * + * @license GNU AGPL version 3 or any later version + * + * 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 + * GNU Affero General Public License for more details. + * + * 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\AppOrder\AppInfo; diff --git a/lib/Controller/AppController.php b/lib/Controller/AppController.php index 4175d85..cb5d8fe 100644 --- a/lib/Controller/AppController.php +++ b/lib/Controller/AppController.php @@ -25,24 +25,24 @@ namespace OCA\AppOrder\Controller; use \OCP\AppFramework\Controller; use OCP\AppFramework\Http\RedirectResponse; -use \OCP\AppFramework\Http\TemplateResponse; use \OCP\IRequest; use \OCP\INavigationManager; use \OCA\AppOrder\Service\ConfigService; use OCA\AppOrder\Util; +use OCP\IURLGenerator; class AppController extends Controller { private $userId; private $appConfig; - private $navigationManager; + private $urlGenerator; private $util; - public function __construct($appName, IRequest $request, ConfigService $appConfig, INavigationManager $navigationManager, Util $util, $userId) { + public function __construct($appName, IRequest $request, ConfigService $appConfig, IURLGenerator $urlGenerator, Util $util, $userId) { parent::__construct($appName, $request); $this->userId = $userId; $this->appConfig = $appConfig; - $this->navigationManager = $navigationManager; + $this->urlGenerator = $urlGenerator; $this->util = $util; } @@ -51,7 +51,12 @@ class AppController extends Controller { * @return RedirectResponse */ public function index() { - $firstPage = json_decode($this->util->getAppOrder())[0]; + $order = json_decode($this->util->getAppOrder()); + if($order !== null && sizeof($order)>0) { + $firstPage = $order[0]; + } else { + return new RedirectResponse($this->urlGenerator->linkTo('files','')); + } return new RedirectResponse($firstPage); } diff --git a/lib/Controller/SettingsController.php b/lib/Controller/SettingsController.php index 3bce7b7..f4186ec 100644 --- a/lib/Controller/SettingsController.php +++ b/lib/Controller/SettingsController.php @@ -16,11 +16,11 @@ class SettingsController extends Controller { private $navigationManager; private $util; - public function __construct($appName, IRequest $request, ConfigService $appConfig, INavigationManager $navigationManager, Util $util, $userId) { + public function __construct($appName, IRequest $request, ConfigService $appConfig, INavigationManager $urlGenerator, Util $util, $userId) { parent::__construct($appName, $request); $this->userId = $userId; $this->appConfig = $appConfig; - $this->navigationManager = $navigationManager; + $this->navigationManager = $urlGenerator; $this->util = $util; } diff --git a/lib/Util.php b/lib/Util.php index 2a2ec5b..e9b35a4 100644 --- a/lib/Util.php +++ b/lib/Util.php @@ -23,7 +23,10 @@ namespace OCA\AppOrder; +use OCA\AppOrder\Service\ConfigService; + class Util { + private $userId; private $appConfig; |