aboutsummaryrefslogtreecommitdiffstats
path: root/apps/sharebymail/lib/Activity.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/sharebymail/lib/Activity.php')
-rw-r--r--apps/sharebymail/lib/Activity.php65
1 files changed, 17 insertions, 48 deletions
diff --git a/apps/sharebymail/lib/Activity.php b/apps/sharebymail/lib/Activity.php
index d1f15eb0e54..2d8289affa4 100644
--- a/apps/sharebymail/lib/Activity.php
+++ b/apps/sharebymail/lib/Activity.php
@@ -1,30 +1,12 @@
<?php
+
/**
- * @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com>
- *
- * @author Bjoern Schiessle <bjoern@schiessle.org>
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Joas Schilling <coding@schilljs.com>
- * @author Morris Jobke <hey@morrisjobke.de>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\ShareByMail;
+use OCP\Activity\Exceptions\UnknownActivityException;
use OCP\Activity\IEvent;
use OCP\Activity\IManager;
use OCP\Activity\IProvider;
@@ -35,23 +17,9 @@ use OCP\IUserManager;
use OCP\L10N\IFactory;
class Activity implements IProvider {
- /** @var IFactory */
- protected $languageFactory;
-
/** @var IL10N */
protected $l;
- /** @var IURLGenerator */
- protected $url;
-
- /** @var IManager */
- protected $activityManager;
-
- /** @var IUserManager */
- protected $userManager;
- /** @var IContactsManager */
- protected $contactsManager;
-
/** @var array */
protected $contactNames = [];
@@ -69,12 +37,13 @@ class Activity implements IProvider {
* @param IUserManager $userManager
* @param IContactsManager $contactsManager
*/
- public function __construct(IFactory $languageFactory, IURLGenerator $url, IManager $activityManager, IUserManager $userManager, IContactsManager $contactsManager) {
- $this->languageFactory = $languageFactory;
- $this->url = $url;
- $this->activityManager = $activityManager;
- $this->userManager = $userManager;
- $this->contactsManager = $contactsManager;
+ public function __construct(
+ protected IFactory $languageFactory,
+ protected IURLGenerator $url,
+ protected IManager $activityManager,
+ protected IUserManager $userManager,
+ protected IContactsManager $contactsManager,
+ ) {
}
/**
@@ -82,12 +51,12 @@ class Activity implements IProvider {
* @param IEvent $event
* @param IEvent|null $previousEvent
* @return IEvent
- * @throws \InvalidArgumentException
+ * @throws UnknownActivityException
* @since 11.0.0
*/
- public function parse($language, IEvent $event, IEvent $previousEvent = null) {
+ public function parse($language, IEvent $event, ?IEvent $previousEvent = null) {
if ($event->getApp() !== 'sharebymail') {
- throw new \InvalidArgumentException();
+ throw new UnknownActivityException();
}
$this->l = $this->languageFactory->get('sharebymail', $language);
@@ -265,12 +234,12 @@ class Activity implements IProvider {
/**
* @param int $id
* @param string $path
- * @return array
+ * @return array<string,string>
*/
- protected function generateFileParameter($id, $path) {
+ protected function generateFileParameter($id, $path): array {
return [
'type' => 'file',
- 'id' => $id,
+ 'id' => (string)$id,
'name' => basename($path),
'path' => trim($path, '/'),
'link' => $this->url->linkToRouteAbsolute('files.viewcontroller.showFile', ['fileid' => $id]),