l10n = $l10n; $this->userSession = $userSession; $this->configService = $configService; $this->urlGenerator = $urlGenerator; } #[\Override] public function preload(IUser $targetUser): void { $this->targetUser = $targetUser; $this->configs = $this->configService->getAllAppointmentConfigurations( $targetUser->getUID(), AppointmentConfig::VISIBILITY_PUBLIC ); } #[\Override] public function getAppId(): string { return Application::APP_ID; } #[\Override] public function getId(): string { return 'appointments'; } #[\Override] public function getDisplayId(): string { return $this->l10n->t('Appointments'); } #[\Override] public function getTitle(): string { if (count($this->configs) === 1) { return $this->l10n->t('Schedule appointment "%s"', [ 'name' => $this->configs[0]->getName(), ]); } return $this->l10n->t('Schedule an appointment'); } #[\Override] public function getPriority(): int { return 50; } #[\Override] public function getIcon(): string { return $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'places/calendar.svg')); } #[\Override] public function getTarget(): ?string { if ($this->configs === []) { return null; } // Directly link to this one appointment if (count($this->configs) === 1) { return $this->urlGenerator->linkToRouteAbsolute( 'calendar.appointment.show', ['token' => $this->configs[0]->getToken()] ); } // Link to the overview page return $this->urlGenerator->linkToRouteAbsolute( 'calendar.appointment.index', ['userId' => $this->targetUser->getUID()] ); } }