Rello /
analytics
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * Analytics |
||
| 4 | * |
||
| 5 | * SPDX-FileCopyrightText: 2019-2022 Marcel Scherello |
||
| 6 | * SPDX-License-Identifier: AGPL-3.0-or-later |
||
| 7 | */ |
||
| 8 | |||
| 9 | declare(strict_types=1); |
||
| 10 | |||
| 11 | namespace OCA\Analytics\Search; |
||
| 12 | |||
| 13 | use OCA\Analytics\Service\ReportService; |
||
| 14 | use OCP\App\IAppManager; |
||
|
0 ignored issues
–
show
|
|||
| 15 | use OCP\IL10N; |
||
|
0 ignored issues
–
show
The type
OCP\IL10N was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 16 | use OCP\IURLGenerator; |
||
|
0 ignored issues
–
show
The type
OCP\IURLGenerator was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 17 | use OCP\IUser; |
||
|
0 ignored issues
–
show
The type
OCP\IUser was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 18 | use OCP\Search\IProvider; |
||
|
0 ignored issues
–
show
The type
OCP\Search\IProvider was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 19 | use OCP\Search\ISearchQuery; |
||
|
0 ignored issues
–
show
The type
OCP\Search\ISearchQuery was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 20 | use OCP\Search\SearchResult; |
||
|
0 ignored issues
–
show
The type
OCP\Search\SearchResult was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 21 | use OCP\Search\SearchResultEntry; |
||
|
0 ignored issues
–
show
The type
OCP\Search\SearchResultEntry was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 22 | |||
| 23 | class SearchProvider implements IProvider |
||
| 24 | { |
||
| 25 | |||
| 26 | /** @var IAppManager */ |
||
| 27 | private $appManager; |
||
| 28 | /** @var IL10N */ |
||
| 29 | private $l10n; |
||
| 30 | /** @var IURLGenerator */ |
||
| 31 | private $urlGenerator; |
||
| 32 | private $ReportService; |
||
| 33 | |||
| 34 | public function __construct(IAppManager $appManager, |
||
| 35 | IL10N $l10n, |
||
| 36 | IURLGenerator $urlGenerator, |
||
| 37 | ReportService $ReportService) |
||
| 38 | { |
||
| 39 | $this->appManager = $appManager; |
||
| 40 | $this->l10n = $l10n; |
||
| 41 | $this->urlGenerator = $urlGenerator; |
||
| 42 | $this->ReportService = $ReportService; |
||
| 43 | } |
||
| 44 | |||
| 45 | public function getId(): string |
||
| 46 | { |
||
| 47 | return 'analytics'; |
||
| 48 | } |
||
| 49 | |||
| 50 | public function search(IUser $user, ISearchQuery $query): SearchResult |
||
| 51 | { |
||
| 52 | if (!$this->appManager->isEnabledForUser('analytics', $user)) { |
||
| 53 | return SearchResult::complete($this->getName(), []); |
||
| 54 | } |
||
| 55 | |||
| 56 | $datasets = $this->ReportService->search($query->getTerm()); |
||
| 57 | $result = []; |
||
| 58 | |||
| 59 | foreach ($datasets as $dataset) { |
||
| 60 | $result[] = new SearchResultEntry( |
||
| 61 | $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('analytics', 'app-dark.svg')), |
||
| 62 | $dataset['name'], |
||
| 63 | '', |
||
| 64 | $this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkToRoute('analytics.page.index') . '#/r/' . $dataset['id']), |
||
| 65 | '' |
||
| 66 | ); |
||
| 67 | } |
||
| 68 | |||
| 69 | return SearchResult::complete( |
||
| 70 | $this->l10n->t('Analytics'), |
||
| 71 | $result |
||
| 72 | ); |
||
| 73 | } |
||
| 74 | |||
| 75 | public function getName(): string |
||
| 76 | { |
||
| 77 | return $this->l10n->t('Analytics'); |
||
| 78 | } |
||
| 79 | |||
| 80 | public function getOrder(string $route, array $routeParameters): int |
||
| 81 | { |
||
| 82 | return 10; |
||
| 83 | } |
||
| 84 | } |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths