aboutsummaryrefslogtreecommitdiffstats
path: root/apps/settings/lib/Activity
diff options
context:
space:
mode:
Diffstat (limited to 'apps/settings/lib/Activity')
-rw-r--r--apps/settings/lib/Activity/GroupProvider.php60
-rw-r--r--apps/settings/lib/Activity/GroupSetting.php37
-rw-r--r--apps/settings/lib/Activity/Provider.php70
-rw-r--r--apps/settings/lib/Activity/SecurityFilter.php35
-rw-r--r--apps/settings/lib/Activity/SecurityProvider.php47
-rw-r--r--apps/settings/lib/Activity/SecuritySetting.php30
-rw-r--r--apps/settings/lib/Activity/Setting.php37
7 files changed, 71 insertions, 245 deletions
diff --git a/apps/settings/lib/Activity/GroupProvider.php b/apps/settings/lib/Activity/GroupProvider.php
index 15b26128890..2d492265cf4 100644
--- a/apps/settings/lib/Activity/GroupProvider.php
+++ b/apps/settings/lib/Activity/GroupProvider.php
@@ -1,29 +1,12 @@
<?php
+
/**
- * @copyright Copyright (c) 2016 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Joas Schilling <coding@schilljs.com>
- *
- * @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\Settings\Activity;
-use InvalidArgumentException;
+use OCP\Activity\Exceptions\UnknownActivityException;
use OCP\Activity\IEvent;
use OCP\Activity\IManager;
use OCP\Activity\IProvider;
@@ -37,36 +20,22 @@ class GroupProvider implements IProvider {
public const ADDED_TO_GROUP = 'group_added';
public const REMOVED_FROM_GROUP = 'group_removed';
- /** @var L10nFactory */
- private $l10n;
- /** @var IURLGenerator */
- private $urlGenerator;
- /** @var IManager */
- private $activityManager;
- /** @var IUserManager */
- protected $userManager;
- /** @var IGroupManager */
- protected $groupManager;
-
/** @var string[] */
protected $groupDisplayNames = [];
- public function __construct(L10nFactory $l10n,
- IURLGenerator $urlGenerator,
- IManager $activityManager,
- IUserManager $userManager,
- IGroupManager $groupManager) {
- $this->urlGenerator = $urlGenerator;
- $this->l10n = $l10n;
- $this->activityManager = $activityManager;
- $this->userManager = $userManager;
- $this->groupManager = $groupManager;
+ public function __construct(
+ private L10nFactory $l10n,
+ private IURLGenerator $urlGenerator,
+ private IManager $activityManager,
+ protected IUserManager $userManager,
+ protected IGroupManager $groupManager,
+ ) {
}
public function parse($language, IEvent $event, ?IEvent $previousEvent = null) {
if ($event->getType() !== 'group_settings') {
- throw new InvalidArgumentException();
+ throw new UnknownActivityException();
}
$l = $this->l10n->get('settings', $language);
@@ -113,7 +82,7 @@ class GroupProvider implements IProvider {
}
break;
default:
- throw new InvalidArgumentException();
+ throw new UnknownActivityException();
}
$this->setSubjects($event, $subject, $parsedParameters);
@@ -121,9 +90,6 @@ class GroupProvider implements IProvider {
return $event;
}
- /**
- * @throws \InvalidArgumentException
- */
protected function setSubjects(IEvent $event, string $subject, array $parameters): void {
$event->setRichSubject($subject, $parameters);
}
diff --git a/apps/settings/lib/Activity/GroupSetting.php b/apps/settings/lib/Activity/GroupSetting.php
index adc7717bf4b..917f4a7ef26 100644
--- a/apps/settings/lib/Activity/GroupSetting.php
+++ b/apps/settings/lib/Activity/GroupSetting.php
@@ -1,25 +1,8 @@
<?php
+
/**
- * @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com>
- *
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Joas Schilling <coding@schilljs.com>
- *
- * @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: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\Settings\Activity;
@@ -28,14 +11,12 @@ use OCP\IL10N;
class GroupSetting implements ISetting {
- /** @var IL10N */
- protected $l;
-
/**
- * @param IL10N $l10n
+ * @param IL10N $l
*/
- public function __construct(IL10N $l10n) {
- $this->l = $l10n;
+ public function __construct(
+ protected IL10N $l,
+ ) {
}
/**
@@ -56,8 +37,8 @@ class GroupSetting implements ISetting {
/**
* @return int whether the filter should be rather on the top or bottom of
- * the admin section. The filters are arranged in ascending order of the
- * priority values. It is required to return a value between 0 and 100.
+ * the admin section. The filters are arranged in ascending order of the
+ * priority values. It is required to return a value between 0 and 100.
* @since 11.0.0
*/
public function getPriority(): int {
diff --git a/apps/settings/lib/Activity/Provider.php b/apps/settings/lib/Activity/Provider.php
index e10e55b5750..c31a900abd5 100644
--- a/apps/settings/lib/Activity/Provider.php
+++ b/apps/settings/lib/Activity/Provider.php
@@ -3,31 +3,12 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com>
- *
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Daniel Kesselberg <mail@danielkesselberg.de>
- * @author Joas Schilling <coding@schilljs.com>
- * @author Thomas Citharel <nextcloud@tcit.fr>
- *
- * @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: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\Settings\Activity;
+use OCP\Activity\Exceptions\UnknownActivityException;
use OCP\Activity\IEvent;
use OCP\Activity\IManager;
use OCP\Activity\IProvider;
@@ -50,29 +31,15 @@ class Provider implements IProvider {
public const APP_TOKEN_FILESYSTEM_GRANTED = 'app_token_filesystem_granted';
public const APP_TOKEN_FILESYSTEM_REVOKED = 'app_token_filesystem_revoked';
- /** @var IFactory */
- protected $languageFactory;
-
/** @var IL10N */
protected $l;
- /** @var IURLGenerator */
- protected $url;
-
- /** @var IUserManager */
- protected $userManager;
-
- /** @var IManager */
- private $activityManager;
-
- public function __construct(IFactory $languageFactory,
- IURLGenerator $url,
- IUserManager $userManager,
- IManager $activityManager) {
- $this->languageFactory = $languageFactory;
- $this->url = $url;
- $this->userManager = $userManager;
- $this->activityManager = $activityManager;
+ public function __construct(
+ protected IFactory $languageFactory,
+ protected IURLGenerator $url,
+ protected IUserManager $userManager,
+ private IManager $activityManager,
+ ) {
}
/**
@@ -80,12 +47,12 @@ class Provider 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): IEvent {
if ($event->getApp() !== 'settings') {
- throw new \InvalidArgumentException('Unknown app');
+ throw new UnknownActivityException('Unknown app');
}
$this->l = $this->languageFactory->get('settings', $language);
@@ -125,7 +92,7 @@ class Provider implements IProvider {
} elseif ($event->getSubject() === self::APP_TOKEN_FILESYSTEM_REVOKED) {
$subject = $this->l->t('You revoked filesystem access from app password "{token}"');
} else {
- throw new \InvalidArgumentException('Unknown subject');
+ throw new UnknownActivityException('Unknown subject');
}
$parsedParameters = $this->getParameters($event);
@@ -137,7 +104,7 @@ class Provider implements IProvider {
/**
* @param IEvent $event
* @return array
- * @throws \InvalidArgumentException
+ * @throws UnknownActivityException
*/
protected function getParameters(IEvent $event): array {
$subject = $event->getSubject();
@@ -162,7 +129,7 @@ class Provider implements IProvider {
return [
'token' => [
'type' => 'highlight',
- 'id' => $event->getObjectId(),
+ 'id' => (string)$event->getObjectId(),
'name' => $parameters['name'],
]
];
@@ -170,23 +137,20 @@ class Provider implements IProvider {
return [
'token' => [
'type' => 'highlight',
- 'id' => $event->getObjectId(),
+ 'id' => (string)$event->getObjectId(),
'name' => $parameters['name'],
],
'newToken' => [
'type' => 'highlight',
- 'id' => $event->getObjectId(),
+ 'id' => (string)$event->getObjectId(),
'name' => $parameters['newName'],
]
];
}
- throw new \InvalidArgumentException('Unknown subject');
+ throw new UnknownActivityException('Unknown subject');
}
- /**
- * @throws \InvalidArgumentException
- */
protected function setSubjects(IEvent $event, string $subject, array $parameters): void {
$event->setRichSubject($subject, $parameters);
}
diff --git a/apps/settings/lib/Activity/SecurityFilter.php b/apps/settings/lib/Activity/SecurityFilter.php
index 48cf6e74f29..9a32e82a984 100644
--- a/apps/settings/lib/Activity/SecurityFilter.php
+++ b/apps/settings/lib/Activity/SecurityFilter.php
@@ -1,24 +1,8 @@
<?php
+
/**
- * @copyright Copyright (c) 2016 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @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\Settings\Activity;
@@ -28,15 +12,10 @@ use OCP\IURLGenerator;
class SecurityFilter implements IFilter {
- /** @var IURLGenerator */
- private $urlGenerator;
-
- /** @var IL10N */
- private $l10n;
-
- public function __construct(IURLGenerator $urlGenerator, IL10N $l10n) {
- $this->urlGenerator = $urlGenerator;
- $this->l10n = $l10n;
+ public function __construct(
+ private IURLGenerator $urlGenerator,
+ private IL10N $l10n,
+ ) {
}
public function allowedApps() {
diff --git a/apps/settings/lib/Activity/SecurityProvider.php b/apps/settings/lib/Activity/SecurityProvider.php
index f847a53d4bf..658e2e7b949 100644
--- a/apps/settings/lib/Activity/SecurityProvider.php
+++ b/apps/settings/lib/Activity/SecurityProvider.php
@@ -3,31 +3,12 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2016 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Joas Schilling <coding@schilljs.com>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @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\Settings\Activity;
-use InvalidArgumentException;
+use OCP\Activity\Exceptions\UnknownActivityException;
use OCP\Activity\IEvent;
use OCP\Activity\IManager;
use OCP\Activity\IProvider;
@@ -36,24 +17,16 @@ use OCP\L10N\IFactory as L10nFactory;
class SecurityProvider implements IProvider {
- /** @var L10nFactory */
- private $l10n;
-
- /** @var IURLGenerator */
- private $urlGenerator;
-
- /** @var IManager */
- private $activityManager;
-
- public function __construct(L10nFactory $l10n, IURLGenerator $urlGenerator, IManager $activityManager) {
- $this->urlGenerator = $urlGenerator;
- $this->l10n = $l10n;
- $this->activityManager = $activityManager;
+ public function __construct(
+ private L10nFactory $l10n,
+ private IURLGenerator $urlGenerator,
+ private IManager $activityManager,
+ ) {
}
public function parse($language, IEvent $event, ?IEvent $previousEvent = null) {
if ($event->getType() !== 'security') {
- throw new InvalidArgumentException();
+ throw new UnknownActivityException();
}
$l = $this->l10n->get('settings', $language);
@@ -104,7 +77,7 @@ class SecurityProvider implements IProvider {
}
break;
default:
- throw new InvalidArgumentException();
+ throw new UnknownActivityException();
}
return $event;
}
diff --git a/apps/settings/lib/Activity/SecuritySetting.php b/apps/settings/lib/Activity/SecuritySetting.php
index 3dc6df4ef2a..9226b5aea5b 100644
--- a/apps/settings/lib/Activity/SecuritySetting.php
+++ b/apps/settings/lib/Activity/SecuritySetting.php
@@ -1,24 +1,8 @@
<?php
+
/**
- * @copyright Copyright (c) 2016 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @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\Settings\Activity;
@@ -27,11 +11,9 @@ use OCP\IL10N;
class SecuritySetting implements ISetting {
- /** @var IL10N */
- private $l10n;
-
- public function __construct(IL10N $l10n) {
- $this->l10n = $l10n;
+ public function __construct(
+ private IL10N $l10n,
+ ) {
}
public function canChangeMail() {
diff --git a/apps/settings/lib/Activity/Setting.php b/apps/settings/lib/Activity/Setting.php
index dc92cea4d8a..f9c659594d6 100644
--- a/apps/settings/lib/Activity/Setting.php
+++ b/apps/settings/lib/Activity/Setting.php
@@ -1,25 +1,8 @@
<?php
+
/**
- * @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com>
- *
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Joas Schilling <coding@schilljs.com>
- *
- * @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: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\Settings\Activity;
@@ -28,14 +11,12 @@ use OCP\IL10N;
class Setting implements ISetting {
- /** @var IL10N */
- protected $l;
-
/**
- * @param IL10N $l10n
+ * @param IL10N $l
*/
- public function __construct(IL10N $l10n) {
- $this->l = $l10n;
+ public function __construct(
+ protected IL10N $l,
+ ) {
}
/**
@@ -56,8 +37,8 @@ class Setting implements ISetting {
/**
* @return int whether the filter should be rather on the top or bottom of
- * the admin section. The filters are arranged in ascending order of the
- * priority values. It is required to return a value between 0 and 100.
+ * the admin section. The filters are arranged in ascending order of the
+ * priority values. It is required to return a value between 0 and 100.
* @since 11.0.0
*/
public function getPriority() {