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 | namespace OCA\Analytics\Activity; |
||
10 | |||
11 | use InvalidArgumentException; |
||
12 | use OCP\Activity\IEvent; |
||
0 ignored issues
–
show
|
|||
13 | use OCP\Activity\IProvider; |
||
0 ignored issues
–
show
The type
OCP\Activity\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 ![]() |
|||
14 | 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 ![]() |
|||
15 | 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 ![]() |
|||
16 | |||
17 | class Provider implements IProvider { |
||
18 | |||
19 | private $l10n; |
||
20 | private $userId; |
||
21 | private $urlGenerator; |
||
22 | |||
23 | public function __construct( |
||
24 | IURLGenerator $urlGenerator, |
||
25 | IL10N $l10n, |
||
26 | $userId |
||
27 | ) { |
||
28 | $this->userId = $userId; |
||
29 | $this->urlGenerator = $urlGenerator; |
||
30 | $this->l10n = $l10n; |
||
31 | } |
||
32 | |||
33 | /** |
||
34 | * @param string $language |
||
35 | * @param IEvent $event |
||
36 | * @param IEvent|null $previousEvent |
||
37 | * @return IEvent |
||
38 | * @throws InvalidArgumentException |
||
39 | * @since 11.0.0 |
||
40 | */ |
||
41 | public function parse($language, IEvent $event, IEvent $previousEvent = null) { |
||
42 | if ($event->getApp() !== 'analytics') { |
||
43 | throw new InvalidArgumentException(); |
||
44 | } |
||
45 | |||
46 | $parsedSubject = ''; |
||
47 | $ownActivity = ($event->getAuthor() === $this->userId); |
||
48 | |||
49 | switch ($event->getSubject()) { |
||
50 | case ActivityManager::SUBJECT_REPORT_ADD: |
||
51 | $parsedSubject = $this->l10n->t('You created a new report: {report}'); |
||
52 | break; |
||
53 | case ActivityManager::SUBJECT_REPORT_DELETE: |
||
54 | $parsedSubject = $this->l10n->t('You deleted the report {report}'); |
||
55 | break; |
||
56 | case ActivityManager::SUBJECT_REPORT_SHARE: |
||
57 | if ($ownActivity) { |
||
58 | $parsedSubject = $this->l10n->t('You shared the report {report}'); |
||
59 | } else { |
||
60 | $parsedSubject = $event->getSubjectParameters()['author'] . ' ' . $this->l10n->t('shared the report {report} with you'); |
||
61 | } |
||
62 | break; |
||
63 | |||
64 | case ActivityManager::SUBJECT_DATASET_ADD: |
||
65 | $parsedSubject = $this->l10n->t('You created a new dataset: {report}'); |
||
66 | break; |
||
67 | case ActivityManager::SUBJECT_DATASET_DELETE: |
||
68 | $parsedSubject = $this->l10n->t('You deleted the dataset {report}'); |
||
69 | break; |
||
70 | case ActivityManager::SUBJECT_DATASET_SHARE: |
||
71 | if ($ownActivity) { |
||
72 | $parsedSubject = $this->l10n->t('You shared the dataset {report}'); |
||
73 | } else { |
||
74 | $parsedSubject = $event->getSubjectParameters()['author'] . ' ' . $this->l10n->t('shared the dataset {report} with you'); |
||
75 | } |
||
76 | break; |
||
77 | |||
78 | case ActivityManager::SUBJECT_PANORAMA_ADD: |
||
79 | $parsedSubject = $this->l10n->t('You created a new panorama: {report}'); |
||
80 | break; |
||
81 | case ActivityManager::SUBJECT_PANORAMA_DELETE: |
||
82 | $parsedSubject = $this->l10n->t('You deleted the panorama {report}'); |
||
83 | break; |
||
84 | case ActivityManager::SUBJECT_PANORAMA_SHARE: |
||
85 | if ($ownActivity) { |
||
86 | $parsedSubject = $this->l10n->t('You shared the panorama {report}'); |
||
87 | } else { |
||
88 | $parsedSubject = $event->getSubjectParameters()['author'] . ' ' . $this->l10n->t('shared the panorama {report} with you'); |
||
89 | } |
||
90 | break; |
||
91 | |||
92 | case ActivityManager::SUBJECT_DATA_ADD: |
||
93 | if ($ownActivity) { |
||
94 | $parsedSubject = $this->l10n->t('You have added new data to dataset {report}'); |
||
95 | } else { |
||
96 | $parsedSubject = $event->getSubjectParameters()['author'] . ' ' . $this->l10n->t('has added new data to dataset {report}'); |
||
97 | } |
||
98 | break; |
||
99 | case ActivityManager::SUBJECT_DATA_ADD_IMPORT: |
||
100 | if ($ownActivity) { |
||
101 | $parsedSubject = $this->l10n->t('You have imported data in dataset {report}'); |
||
102 | } else { |
||
103 | $parsedSubject = $event->getSubjectParameters()['author'] . ' ' . $this->l10n->t('has imported data in dataset {report}'); |
||
104 | } |
||
105 | break; |
||
106 | case ActivityManager::SUBJECT_DATA_ADD_API: |
||
107 | $parsedSubject = $this->l10n->t('New data has been added to dataset {report} via API'); |
||
108 | break; |
||
109 | case ActivityManager::SUBJECT_DATA_ADD_DATALOAD: |
||
110 | $parsedSubject = $this->l10n->t('New data has been added to dataset {report} via data load'); |
||
111 | break; |
||
112 | } |
||
113 | |||
114 | $event->setRichSubject($parsedSubject, [ |
||
115 | 'report' => [ |
||
116 | 'type' => 'highlight', |
||
117 | 'id' => $event->getObjectId(), |
||
118 | 'name' => '"' . basename($event->getObjectName()) . '"', |
||
119 | 'link' => $this->Url($event->getObjectId()), |
||
120 | ] |
||
121 | ]); |
||
122 | |||
123 | $event->setParsedSubject($parsedSubject) |
||
124 | ->setIcon($this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath($event->getApp(), 'app-dark.svg'))); |
||
125 | return $event; |
||
126 | } |
||
127 | |||
128 | public function Url($endpoint) { |
||
129 | return $this->urlGenerator->linkToRouteAbsolute('analytics.page.index') . '#/r/' . $endpoint; |
||
130 | } |
||
131 | } |
||
132 |
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