. * */ namespace OCA\Passman\Search; use OCA\Passman\AppInfo\Application; use OCP\IL10N; use OCP\IURLGenerator; use OCP\IUser; use OCP\Search\IProvider; use OCP\Search\ISearchQuery; use OCP\Search\SearchResult; use OCP\Search\SearchResultEntry; class Provider implements IProvider { /** @var IL10N */ private IL10N $l10n; /** @var IURLGenerator */ private IURLGenerator $urlGenerator; public function __construct(IL10N $l10n, IURLGenerator $urlGenerator) { $this->l10n = $l10n; $this->urlGenerator = $urlGenerator; } public function getId(): string { return Application::APP_ID; } public function getName(): string { return $this->l10n->t('Passman'); } public function getOrder(string $route, array $routeParameters): int { if (strpos($route, Application::APP_ID . '.') === 0) { // Active app, prefer my results return -1; } return 25; } public function search(IUser $user, ISearchQuery $query): SearchResult { return SearchResult::complete( $this->l10n->t(Application::APP_ID), [ new SearchResultEntry( $this->urlGenerator->imagePath(Application::APP_ID, 'app.svg'), $this->l10n->t('Search in current page'), $this->l10n->t('This requires an already unlocked Passman vault'), '#?search=' . $query->getTerm() ) ] ); } }