]> source.dussan.org Git - nextcloud-server.git/commitdiff
Lazy register the navigation 21767/head
authorRoeland Jago Douma <roeland@famdouma.nl>
Thu, 9 Jul 2020 07:48:09 +0000 (09:48 +0200)
committerMorris Jobke <hey@morrisjobke.de>
Thu, 9 Jul 2020 08:12:53 +0000 (10:12 +0200)
This makes sure that we do not translate unneeded strings on for example
webdav requests.

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
apps/files/lib/AppInfo/Application.php
apps/files_sharing/lib/AppInfo/Application.php

index 5e473c411ee1953f9a7c11a8f10d99c5f25c1e21..9500f91fdf99a146238dc4c96bbcfdcfa43b52c9 100644 (file)
@@ -153,28 +153,34 @@ class Application extends App implements IBootstrap {
        private function registerNavigation(IBootContext $context): void {
                /** @var IL10N $l10n */
                $l10n = $context->getAppContainer()->query(IL10N::class);
-               \OCA\Files\App::getNavigationManager()->add([
-                       'id' => 'files',
-                       'appname' => 'files',
-                       'script' => 'list.php',
-                       'order' => 0,
-                       'name' => $l10n->t('All files')
-               ]);
-               \OCA\Files\App::getNavigationManager()->add([
-                       'id' => 'recent',
-                       'appname' => 'files',
-                       'script' => 'recentlist.php',
-                       'order' => 2,
-                       'name' => $l10n->t('Recent')
-               ]);
-               \OCA\Files\App::getNavigationManager()->add([
-                       'id' => 'favorites',
-                       'appname' => 'files',
-                       'script' => 'simplelist.php',
-                       'order' => 5,
-                       'name' => $l10n->t('Favorites'),
-                       'expandedState' => 'show_Quick_Access'
-               ]);
+               \OCA\Files\App::getNavigationManager()->add(function () use ($l10n) {
+                       return [
+                               'id' => 'files',
+                               'appname' => 'files',
+                               'script' => 'list.php',
+                               'order' => 0,
+                               'name' => $l10n->t('All files')
+                       ];
+               });
+               \OCA\Files\App::getNavigationManager()->add(function () use ($l10n) {
+                       return [
+                               'id' => 'recent',
+                               'appname' => 'files',
+                               'script' => 'recentlist.php',
+                               'order' => 2,
+                               'name' => $l10n->t('Recent')
+                       ];
+               });
+               \OCA\Files\App::getNavigationManager()->add(function () use ($l10n) {
+                       return [
+                               'id' => 'favorites',
+                               'appname' => 'files',
+                               'script' => 'simplelist.php',
+                               'order' => 5,
+                               'name' => $l10n->t('Favorites'),
+                               'expandedState' => 'show_Quick_Access'
+                       ];
+               });
        }
 
        private function registerHooks(): void {
index 985154091869df4b1072c18b6c703b5258c92fef..34cde50c43843cffdcdf706d4fa3d737c22c4913 100644 (file)
@@ -161,72 +161,75 @@ class Application extends App {
 
        protected function setupSharingMenus() {
                $config = \OC::$server->getConfig();
-               $l = \OC::$server->getL10N('files_sharing');
 
                if ($config->getAppValue('core', 'shareapi_enabled', 'yes') !== 'yes') {
                        return;
                }
 
-               $sharingSublistArray = [];
+               // show_Quick_Access stored as string
+               \OCA\Files\App::getNavigationManager()->add(function () {
+                       $config = \OC::$server->getConfig();
+                       $l = \OC::$server->getL10N('files_sharing');
 
-               if (\OCP\Util::isSharingDisabledForUser() === false) {
-                       array_push($sharingSublistArray, [
-                               'id' => 'sharingout',
-                               'appname' => 'files_sharing',
-                               'script' => 'list.php',
-                               'order' => 16,
-                               'name' => $l->t('Shared with others'),
-                       ]);
-               }
+                       $sharingSublistArray = [];
 
-               array_push($sharingSublistArray, [
-                       'id' => 'sharingin',
-                       'appname' => 'files_sharing',
-                       'script' => 'list.php',
-                       'order' => 15,
-                       'name' => $l->t('Shared with you'),
-               ]);
-
-               if (\OCP\Util::isSharingDisabledForUser() === false) {
-                       // Check if sharing by link is enabled
-                       if ($config->getAppValue('core', 'shareapi_allow_links', 'yes') === 'yes') {
-                               array_push($sharingSublistArray, [
-                                       'id' => 'sharinglinks',
+                       if (\OCP\Util::isSharingDisabledForUser() === false) {
+                               $sharingSublistArray[] = [
+                                       'id' => 'sharingout',
                                        'appname' => 'files_sharing',
                                        'script' => 'list.php',
-                                       'order' => 17,
-                                       'name' => $l->t('Shared by link'),
-                               ]);
+                                       'order' => 16,
+                                       'name' => $l->t('Shared with others'),
+                               ];
                        }
-               }
 
-               array_push($sharingSublistArray, [
-                       'id' => 'deletedshares',
-                       'appname' => 'files_sharing',
-                       'script' => 'list.php',
-                       'order' => 19,
-                       'name' => $l->t('Deleted shares'),
-               ]);
+                       $sharingSublistArray[] = [
+                               'id' => 'sharingin',
+                               'appname' => 'files_sharing',
+                               'script' => 'list.php',
+                               'order' => 15,
+                               'name' => $l->t('Shared with you'),
+                       ];
+
+                       if (\OCP\Util::isSharingDisabledForUser() === false) {
+                               // Check if sharing by link is enabled
+                               if ($config->getAppValue('core', 'shareapi_allow_links', 'yes') === 'yes') {
+                                       $sharingSublistArray[] = [
+                                               'id' => 'sharinglinks',
+                                               'appname' => 'files_sharing',
+                                               'script' => 'list.php',
+                                               'order' => 17,
+                                               'name' => $l->t('Shared by link'),
+                                       ];
+                               }
+                       }
 
-               array_push($sharingSublistArray, [
-                       'id' => 'pendingshares',
-                       'appname' => 'files_sharing',
-                       'script' => 'list.php',
-                       'order' => 19,
-                       'name' => $l->t('Pending shares'),
-               ]);
+                       $sharingSublistArray[] = [
+                               'id' => 'deletedshares',
+                               'appname' => 'files_sharing',
+                               'script' => 'list.php',
+                               'order' => 19,
+                               'name' => $l->t('Deleted shares'),
+                       ];
 
+                       $sharingSublistArray[] = [
+                               'id' => 'pendingshares',
+                               'appname' => 'files_sharing',
+                               'script' => 'list.php',
+                               'order' => 19,
+                               'name' => $l->t('Pending shares'),
+                       ];
 
-               // show_Quick_Access stored as string
-               \OCA\Files\App::getNavigationManager()->add([
-                       'id' => 'shareoverview',
-                       'appname' => 'files_sharing',
-                       'script' => 'list.php',
-                       'order' => 18,
-                       'name' => $l->t('Shares'),
-                       'classes' => 'collapsible',
-                       'sublist' => $sharingSublistArray,
-                       'expandedState' => 'show_sharing_menu'
-               ]);
+                       return [
+                               'id' => 'shareoverview',
+                               'appname' => 'files_sharing',
+                               'script' => 'list.php',
+                               'order' => 18,
+                               'name' => $l->t('Shares'),
+                               'classes' => 'collapsible',
+                               'sublist' => $sharingSublistArray,
+                               'expandedState' => 'show_sharing_menu'
+                       ];
+               });
        }
 }