-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
114 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?php | ||
/** | ||
* Analytics | ||
* | ||
* This file is licensed under the Affero General Public License version 3 or | ||
* later. See the LICENSE.md file. | ||
* | ||
* @author Marcel Scherello <audioplayer@scherello.de> | ||
* @copyright 2020 Marcel Scherello | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OCA\Analytics\Search; | ||
|
||
use OCA\Analytics\Controller\DatasetController; | ||
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 $l10n; | ||
|
||
/** @var IURLGenerator */ | ||
private $urlGenerator; | ||
|
||
private $datasetController; | ||
|
||
public function __construct(IL10N $l10n, | ||
IURLGenerator $urlGenerator, | ||
DatasetController $datasetController) | ||
{ | ||
$this->l10n = $l10n; | ||
$this->urlGenerator = $urlGenerator; | ||
$this->datasetController = $datasetController; | ||
} | ||
|
||
public function getId(): string | ||
{ | ||
return 'analytics'; | ||
} | ||
|
||
public function search(IUser $user, ISearchQuery $query): SearchResult | ||
{ | ||
$datasets = $this->datasetController->search($query->getTerm()); | ||
|
||
foreach ($datasets as $dataset) { | ||
$result[] = new SearchResultEntry( | ||
'', | ||
$dataset['name'], | ||
'', | ||
$this->urlGenerator->linkToRoute('analytics.page.index') . '#/r/' . $dataset['id'], | ||
$this->urlGenerator->imagePath('analytics', 'app-dark.svg') | ||
); | ||
} | ||
|
||
return SearchResult::complete( | ||
$this->l10n->t('Analytics'), | ||
$result | ||
); | ||
} | ||
|
||
public function getName(): string | ||
{ | ||
return $this->l10n->t('Analytics'); | ||
} | ||
|
||
public function getOrder(string $route, array $routeParameters): int | ||
{ | ||
return 10; | ||
} | ||
} |