namespace OC;
+use OC\App\AppManager;
use OCP\App\IAppManager;
use OCP\IGroupManager;
use OCP\INavigationManager;
protected $activeEntry;
/** @var bool */
protected $init = false;
- /** @var IAppManager */
+ /** @var IAppManager|AppManager */
protected $appManager;
/** @var IURLGenerator */
private $urlGenerator;
/** @var IGroupManager */
private $groupManager;
- function __construct(IAppManager $appManager = null,
+ public function __construct(IAppManager $appManager = null,
IURLGenerator $urlGenerator = null,
IFactory $l10nFac = null,
IUserSession $userSession = null,
continue;
}
$nav = $info['navigation'];
+ if (!isset($nav['name'])) {
+ continue;
+ }
if (!isset($nav['route'])) {
continue;
}
$l = $this->l10nFac->get($app);
$order = isset($nav['order']) ? $nav['order'] : 100;
$route = $this->urlGenerator->linkToRoute($nav['route']);
- $name = isset($nav['name']) ? $nav['name'] : ucfirst($app);
$icon = isset($nav['icon']) ? $nav['icon'] : 'app.svg';
foreach ([$icon, "$app.svg"] as $i) {
try {
'order' => $order,
'href' => $route,
'icon' => $icon,
- 'name' => $l->t($name),
+ 'name' => $l->t($nav['name']),
]);
}
}
namespace Test;
+use OC\App\AppManager;
use OC\NavigationManager;
use OCP\App\IAppManager;
use OCP\IGroupManager;
*/
public function testWithAppManager($expected, $config, $isAdmin = false) {
- $appManager = $this->createMock(IAppManager::class);
+ $appManager = $this->createMock(AppManager::class);
$urlGenerator = $this->createMock(IURLGenerator::class);
$l10nFac = $this->createMock(IFactory::class);
$userSession = $this->createMock(IUserSession::class);
'icon' => '/apps/test/img/app.svg',
'name' => 'Test',
'active' => false
- ]], ['navigation' => ['route' => 'test.page.index']]],
+ ]], ['navigation' => ['route' => 'test.page.index', 'name' => 'Test']]],
'no admin' => [[[
'id' => 'test',
'order' => 100,
'icon' => '/apps/test/img/app.svg',
'name' => 'Test',
'active' => false
- ]], ['navigation' => ['@attributes' => ['role' => 'admin'], 'route' => 'test.page.index']], true],
- 'admin' => [[], ['navigation' => ['@attributes' => ['role' => 'admin'], 'route' => 'test.page.index']]]
+ ]], ['navigation' => ['@attributes' => ['role' => 'admin'], 'route' => 'test.page.index', 'name' => 'Test']], true],
+ 'no name' => [[], ['navigation' => ['@attributes' => ['role' => 'admin'], 'route' => 'test.page.index']], true],
+ 'admin' => [[], ['navigation' => ['@attributes' => ['role' => 'admin'], 'route' => 'test.page.index', 'name' => 'Test']]]
];
}
}