Skip to content

Commit

Permalink
remove usages of deprecated OCA\Files\App::getNavigationManager
Browse files Browse the repository at this point in the history
Signed-off-by: Robin Appelman <[email protected]>
  • Loading branch information
icewind1991 committed Mar 26, 2021
1 parent 92fd92d commit 1aa103e
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 37 deletions.
9 changes: 5 additions & 4 deletions apps/files/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
use OCA\Files\Notification\Notifier;
use OCA\Files\Search\FilesSearchProvider;
use OCA\Files\Service\TagService;
use OCA\Files\SidebarNavigationManager;
use OCP\Activity\IManager as IActivityManager;
use OCP\AppFramework\App;
use OCP\AppFramework\Bootstrap\IBootContext;
Expand Down Expand Up @@ -149,8 +150,8 @@ private function registerTemplates(): void {
$templateManager->registerTemplate('application/vnd.oasis.opendocument.spreadsheet', 'core/templates/filetemplates/template.ods');
}

private function registerNavigation(IL10N $l10n): void {
\OCA\Files\App::getNavigationManager()->add(function () use ($l10n) {
private function registerNavigation(IL10N $l10n, SidebarNavigationManager $navigation): void {
$navigation->add(function () use ($l10n) {
return [
'id' => 'files',
'appname' => 'files',
Expand All @@ -159,7 +160,7 @@ private function registerNavigation(IL10N $l10n): void {
'name' => $l10n->t('All files')
];
});
\OCA\Files\App::getNavigationManager()->add(function () use ($l10n) {
$navigation->add(function () use ($l10n) {
return [
'id' => 'recent',
'appname' => 'files',
Expand All @@ -168,7 +169,7 @@ private function registerNavigation(IL10N $l10n): void {
'name' => $l10n->t('Recent')
];
});
\OCA\Files\App::getNavigationManager()->add(function () use ($l10n) {
$navigation->add(function () use ($l10n) {
return [
'id' => 'favorites',
'appname' => 'files',
Expand Down
25 changes: 16 additions & 9 deletions apps/files/lib/Controller/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@

use OC\Files\Node\Node;
use OCA\Files\Service\TagService;
use OCA\Files\SidebarNavigationManager;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataResponse;
Expand Down Expand Up @@ -73,6 +74,8 @@ class ApiController extends Controller {
private $config;
/** @var Folder */
private $userFolder;
/** @var SidebarNavigationManager */
private $navigationManager;

/**
* @param string $appName
Expand All @@ -84,21 +87,25 @@ class ApiController extends Controller {
* @param IConfig $config
* @param Folder $userFolder
*/
public function __construct($appName,
IRequest $request,
IUserSession $userSession,
TagService $tagService,
IPreview $previewManager,
IManager $shareManager,
IConfig $config,
Folder $userFolder) {
public function __construct(
$appName,
IRequest $request,
IUserSession $userSession,
TagService $tagService,
IPreview $previewManager,
IManager $shareManager,
IConfig $config,
Folder $userFolder,
SidebarNavigationManager $navigationManager
) {
parent::__construct($appName, $request);
$this->userSession = $userSession;
$this->tagService = $tagService;
$this->previewManager = $previewManager;
$this->shareManager = $shareManager;
$this->config = $config;
$this->userFolder = $userFolder;
$this->navigationManager = $navigationManager;
}

/**
Expand Down Expand Up @@ -331,7 +338,7 @@ public function getGridView() {
*/
public function toggleShowFolder(int $show, string $key) {
// ensure the edited key exists
$navItems = \OCA\Files\App::getNavigationManager()->getAll();
$navItems = $this->navigationManager->getAll();
foreach ($navItems as $item) {
// check if data is valid
if (($show === 0 || $show === 1) && isset($item['expandedState']) && $key === $item['expandedState']) {
Expand Down
9 changes: 7 additions & 2 deletions apps/files/lib/Controller/ViewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
use OCA\Files\Activity\Helper;
use OCA\Files\Event\LoadAdditionalScriptsEvent;
use OCA\Files\Event\LoadSidebar;
use OCA\Files\SidebarNavigationManager;
use OCA\Viewer\Event\LoadViewer;
use OCP\App\IAppManager;
use OCP\AppFramework\Controller;
Expand Down Expand Up @@ -86,6 +87,8 @@ class ViewController extends Controller {
private $initialState;
/** @var ITemplateManager */
private $templateManager;
/** @var SidebarNavigationManager */
private $navigationManager;

public function __construct(string $appName,
IRequest $request,
Expand All @@ -98,7 +101,8 @@ public function __construct(string $appName,
IRootFolder $rootFolder,
Helper $activityHelper,
IInitialState $initialState,
ITemplateManager $templateManager
ITemplateManager $templateManager,
SidebarNavigationManager $navigationManager
) {
parent::__construct($appName, $request);
$this->appName = $appName;
Expand All @@ -113,6 +117,7 @@ public function __construct(string $appName,
$this->activityHelper = $activityHelper;
$this->initialState = $initialState;
$this->templateManager = $templateManager;
$this->navigationManager = $navigationManager;
}

/**
Expand Down Expand Up @@ -233,7 +238,7 @@ public function index($dir = '', $view = '', $fileid = null, $fileNotFound = fal
$navBarPositionPosition++;
}

$navItems = \OCA\Files\App::getNavigationManager()->getAll();
$navItems = $this->navigationManager->getAll();

// add the favorites entry in menu
$navItems['favorites']['sublist'] = $favoritesSublistArray;
Expand Down
4 changes: 3 additions & 1 deletion apps/files_external/appinfo/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
*
*/

use OCA\Files\SidebarNavigationManager;
use OCA\Files_External\Config\ConfigAdapter;

require_once __DIR__ . '/../3rdparty/autoload.php';
Expand All @@ -36,7 +37,8 @@

$appContainer = \OCA\Files_External\MountConfig::$app->getContainer();

\OCA\Files\App::getNavigationManager()->add(function () {
$navigationManager = $appContainer->get(SidebarNavigationManager::class);
$navigationManager->add(function () {
$l = \OC::$server->getL10N('files_external');
return [
'id' => 'extstoragemounts',
Expand Down
6 changes: 4 additions & 2 deletions apps/files_sharing/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
namespace OCA\Files_Sharing\AppInfo;

use OC\AppFramework\Utility\SimpleContainer;
use OCA\Files\SidebarNavigationManager;
use OCA\Files_Sharing\Capabilities;
use OCA\Files_Sharing\Event\BeforeTemplateRenderedEvent;
use OCA\Files_Sharing\External\Manager;
Expand Down Expand Up @@ -172,9 +173,10 @@ protected function setupSharingMenus() {
return;
}

/** @var SidebarNavigationManager $navigationManager */
$navigationManager = $this->getContainer()->get(SidebarNavigationManager::class);
// show_Quick_Access stored as string
\OCA\Files\App::getNavigationManager()->add(function () {
$config = \OC::$server->getConfig();
$navigationManager->add(function () use ($config) {
$l = \OC::$server->getL10N('files_sharing');

$sharingSublistArray = [];
Expand Down
23 changes: 13 additions & 10 deletions apps/files_trashbin/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
namespace OCA\Files_Trashbin\AppInfo;

use OCA\DAV\Connector\Sabre\Principal;
use OCA\Files\SidebarNavigationManager;
use OCA\Files_Trashbin\Capabilities;
use OCA\Files_Trashbin\Expiration;
use OCA\Files_Trashbin\Trash\ITrashManager;
Expand Down Expand Up @@ -65,16 +66,18 @@ public function boot(IBootContext $context): void {
// pre and post-rename, disable trash logic for the copy+unlink case
\OCP\Util::connectHook('OC_Filesystem', 'delete', 'OCA\Files_Trashbin\Trashbin', 'ensureFileScannedHook');

\OCA\Files\App::getNavigationManager()->add(function () {
$l = \OC::$server->getL10N('files_trashbin');
return [
'id' => 'trashbin',
'appname' => 'files_trashbin',
'script' => 'list.php',
'order' => 50,
'name' => $l->t('Deleted files'),
'classes' => 'pinned',
];
$context->injectFn(function (SidebarNavigationManager $navigationManager) {
$navigationManager->add(function () {
$l = \OC::$server->getL10N('files_trashbin');
return [
'id' => 'trashbin',
'appname' => 'files_trashbin',
'script' => 'list.php',
'order' => 50,
'name' => $l->t('Deleted files'),
'classes' => 'pinned',
];
});
});
}

Expand Down
21 changes: 12 additions & 9 deletions apps/systemtags/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

namespace OCA\SystemTags\AppInfo;

use OCA\Files\SidebarNavigationManager;
use OCA\SystemTags\Activity\Listener;
use OCP\AppFramework\App;
use OCP\AppFramework\Bootstrap\IBootContext;
Expand Down Expand Up @@ -77,15 +78,17 @@ function () {
$dispatcher->addListener(MapperEvent::EVENT_UNASSIGN, $mapperListener);
});

\OCA\Files\App::getNavigationManager()->add(function () {
$l = \OC::$server->getL10N(self::APP_ID);
return [
'id' => 'systemtagsfilter',
'appname' => self::APP_ID,
'script' => 'list.php',
'order' => 25,
'name' => $l->t('Tags'),
];
$context->injectFn(function (SidebarNavigationManager $navigationManager) {
$navigationManager->add(function () {
$l = \OC::$server->getL10N(self::APP_ID);
return [
'id' => 'systemtagsfilter',
'appname' => self::APP_ID,
'script' => 'list.php',
'order' => 25,
'name' => $l->t('Tags'),
];
});
});
}
}

0 comments on commit 1aa103e

Please sign in to comment.