diff --git a/appinfo/info.xml b/appinfo/info.xml
index 6e5846a..a872b36 100644
--- a/appinfo/info.xml
+++ b/appinfo/info.xml
@@ -14,13 +14,4 @@
-
-
- office
- Office
- office.page.index
- app.svg
- link
-
-
diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php
index 68a6009..501f131 100644
--- a/lib/AppInfo/Application.php
+++ b/lib/AppInfo/Application.php
@@ -5,6 +5,7 @@
namespace OCA\Office\AppInfo;
use OCA\Office\Listener\AppMenuActionListener;
+use OCA\Office\Listener\LoadNavigationEntryListener;
use OCP\AppFramework\App;
use OCP\AppFramework\Bootstrap\IBootContext;
use OCP\AppFramework\Bootstrap\IBootstrap;
@@ -22,6 +23,7 @@ public function __construct() {
#[\Override]
public function register(IRegistrationContext $context): void {
$context->registerEventListener(LoadAdditionalEntriesEvent::class, AppMenuActionListener::class);
+ $context->registerEventListener(LoadAdditionalEntriesEvent::class, LoadNavigationEntryListener::class);
}
#[\Override]
diff --git a/lib/Listener/LoadNavigationEntryListener.php b/lib/Listener/LoadNavigationEntryListener.php
new file mode 100644
index 0000000..6fee3d1
--- /dev/null
+++ b/lib/Listener/LoadNavigationEntryListener.php
@@ -0,0 +1,43 @@
+
+ */
+final class LoadNavigationEntryListener implements IEventListener {
+ /** @psalm-suppress PossiblyUnusedMethod Constructed by the DI container */
+ public function __construct(
+ private INavigationManager $navigationManager,
+ private IURLGenerator $urlGenerator,
+ ) {
+ }
+
+ #[\Override]
+ public function handle(Event $event): void {
+ if (!$event instanceof LoadAdditionalEntriesEvent) {
+ return;
+ }
+
+ $this->navigationManager->add([
+ 'id' => Application::APP_ID,
+ 'type' => 'link',
+ 'order' => 10,
+ 'href' => $this->urlGenerator->linkToRoute(Application::APP_ID . '.page.index'),
+ 'icon' => $this->urlGenerator->imagePath(Application::APP_ID, 'app.svg'),
+ 'name' => 'Office',
+ ]);
+ }
+}
diff --git a/tests/unit/Listener/LoadNavigationEntryListenerTest.php b/tests/unit/Listener/LoadNavigationEntryListenerTest.php
new file mode 100644
index 0000000..ecceec0
--- /dev/null
+++ b/tests/unit/Listener/LoadNavigationEntryListenerTest.php
@@ -0,0 +1,46 @@
+navigationManager = $this->createMock(INavigationManager::class);
+ $urlGenerator = $this->createMock(IURLGenerator::class);
+ $urlGenerator->method('linkToRoute')->willReturn('/apps/office/');
+ $urlGenerator->method('imagePath')->willReturn('/apps/office/img/app.svg');
+
+ $this->listener = new LoadNavigationEntryListener($this->navigationManager, $urlGenerator);
+ }
+
+ public function testRegistersTheUntranslatedAppEntry(): void {
+ $this->navigationManager->expects($this->once())
+ ->method('add')
+ ->with($this->callback(static fn (array $entry): bool => $entry['id'] === 'office'
+ && $entry['name'] === 'Office'
+ && $entry['href'] === '/apps/office/'
+ && $entry['icon'] === '/apps/office/img/app.svg'));
+
+ $this->listener->handle(new LoadAdditionalEntriesEvent());
+ }
+
+ public function testIgnoresOtherEvents(): void {
+ $this->navigationManager->expects($this->never())->method('add');
+
+ $this->listener->handle(new Event());
+ }
+}