Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
move files sidebar navigation manager into it's own service
Signed-off-by: Robin Appelman <[email protected]>
  • Loading branch information
icewind1991 committed Mar 26, 2021
commit 71b61e90012d7614a663801c14e78e047fd7833c
1 change: 1 addition & 0 deletions apps/files/composer/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,5 @@
'OCA\\Files\\Service\\OwnershipTransferService' => $baseDir . '/../lib/Service/OwnershipTransferService.php',
'OCA\\Files\\Service\\TagService' => $baseDir . '/../lib/Service/TagService.php',
'OCA\\Files\\Settings\\PersonalSettings' => $baseDir . '/../lib/Settings/PersonalSettings.php',
'OCA\\Files\\SidebarNavigationManager' => $baseDir . '/../lib/SidebarNavigationManager.php',
);
1 change: 1 addition & 0 deletions apps/files/composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class ComposerStaticInitFiles
'OCA\\Files\\Service\\OwnershipTransferService' => __DIR__ . '/..' . '/../lib/Service/OwnershipTransferService.php',
'OCA\\Files\\Service\\TagService' => __DIR__ . '/..' . '/../lib/Service/TagService.php',
'OCA\\Files\\Settings\\PersonalSettings' => __DIR__ . '/..' . '/../lib/Settings/PersonalSettings.php',
'OCA\\Files\\SidebarNavigationManager' => __DIR__ . '/..' . '/../lib/SidebarNavigationManager.php',
);

public static function getInitializer(ClassLoader $loader)
Expand Down
25 changes: 5 additions & 20 deletions apps/files/lib/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,31 +25,16 @@

namespace OCA\Files;

class App {
/**
* @var \OCP\INavigationManager
*/
private static $navigationManager;
use OCP\INavigationManager;

class App {
/**
* Returns the app's navigation manager
*
* @return \OCP\INavigationManager
* @return INavigationManager
*/
public static function getNavigationManager() {
// TODO: move this into a service in the Application class
if (self::$navigationManager === null) {
self::$navigationManager = new \OC\NavigationManager(
\OC::$server->getAppManager(),
\OC::$server->getURLGenerator(),
\OC::$server->getL10NFactory(),
\OC::$server->getUserSession(),
\OC::$server->getGroupManager(),
\OC::$server->getConfig()
);
self::$navigationManager->clear(false);
}
return self::$navigationManager;
public static function getNavigationManager(): INavigationManager {
return \OC::$server->get(SidebarNavigationManager::class);
}

public static function extendJsConfig($settings) {
Expand Down
32 changes: 32 additions & 0 deletions apps/files/lib/SidebarNavigationManager.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

declare(strict_types=1);
/**
* @copyright Copyright (c) 2021 Robin Appelman <[email protected]>
*
* @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\Files;

use OC\NavigationManager;

class SidebarNavigationManager extends NavigationManager {
protected function init() {
// don't load the normal navigation items
}
}
2 changes: 1 addition & 1 deletion lib/private/NavigationManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public function getActiveEntry() {
return $this->activeEntry;
}

private function init() {
protected function init() {
if ($this->init) {
return;
}
Expand Down