diff options
Diffstat (limited to 'apps/updatenotification/lib')
-rw-r--r-- | apps/updatenotification/lib/Settings/Admin.php | 56 |
1 files changed, 18 insertions, 38 deletions
diff --git a/apps/updatenotification/lib/Settings/Admin.php b/apps/updatenotification/lib/Settings/Admin.php index b8062efd81f..fded4451408 100644 --- a/apps/updatenotification/lib/Settings/Admin.php +++ b/apps/updatenotification/lib/Settings/Admin.php @@ -33,6 +33,7 @@ use OC\User\Backend; use OCP\User\Backend\ICountUsersBackend; use OCA\UpdateNotification\UpdateChecker; use OCP\AppFramework\Http\TemplateResponse; +use OCP\AppFramework\Services\IInitialState; use OCP\IConfig; use OCP\IDateTimeFormatter; use OCP\IGroupManager; @@ -44,22 +45,15 @@ use OCP\IUserManager; use Psr\Log\LoggerInterface; class Admin implements ISettings { - /** @var IConfig */ - private $config; - /** @var UpdateChecker */ - private $updateChecker; - /** @var IGroupManager */ - private $groupManager; - /** @var IDateTimeFormatter */ - private $dateTimeFormatter; - /** @var IFactory */ - private $l10nFactory; - /** @var IRegistry */ - private $subscriptionRegistry; - /** @var IUserManager */ - private $userManager; - /** @var LoggerInterface */ - private $logger; + private IConfig $config; + private UpdateChecker $updateChecker; + private IGroupManager $groupManager; + private IDateTimeFormatter $dateTimeFormatter; + private IFactory $l10nFactory; + private IRegistry $subscriptionRegistry; + private IUserManager $userManager; + private LoggerInterface $logger; + private IInitialState $initialState; public function __construct( IConfig $config, @@ -69,7 +63,8 @@ class Admin implements ISettings { IFactory $l10nFactory, IRegistry $subscriptionRegistry, IUserManager $userManager, - LoggerInterface $logger + LoggerInterface $logger, + IInitialState $initialState ) { $this->config = $config; $this->updateChecker = $updateChecker; @@ -79,11 +74,9 @@ class Admin implements ISettings { $this->subscriptionRegistry = $subscriptionRegistry; $this->userManager = $userManager; $this->logger = $logger; + $this->initialState = $initialState; } - /** - * @return TemplateResponse - */ public function getForm(): TemplateResponse { $lastUpdateCheckTimestamp = $this->config->getAppValue('core', 'lastupdatedat'); $lastUpdateCheck = $this->dateTimeFormatter->formatDateTime($lastUpdateCheckTimestamp); @@ -131,12 +124,9 @@ class Admin implements ISettings { 'notifyGroups' => $this->getSelectedGroups($notifyGroups), 'hasValidSubscription' => $hasValidSubscription, ]; + $this->initialState->provideInitialState('data', $params); - $params = [ - 'json' => json_encode($params), - ]; - - return new TemplateResponse('updatenotification', 'admin', $params, ''); + return new TemplateResponse('updatenotification', 'admin', [], ''); } protected function filterChanges(array $changes): array { @@ -162,8 +152,8 @@ class Admin implements ISettings { } /** - * @param array $groupIds - * @return array + * @param list<string> $groupIds + * @return list<array{id: string, displayname: string}> */ protected function getSelectedGroups(array $groupIds): array { $result = []; @@ -174,26 +164,16 @@ class Admin implements ISettings { continue; } - $result[] = ['value' => $group->getGID(), 'label' => $group->getDisplayName()]; + $result[] = ['id' => $group->getGID(), 'displayname' => $group->getDisplayName()]; } return $result; } - /** - * @return string the section ID, e.g. 'sharing' - */ public function getSection(): string { return 'overview'; } - /** - * @return int whether the form should be rather on the top or bottom of - * the admin section. The forms are arranged in ascending order of the - * priority values. It is required to return a value between 0 and 100. - * - * E.g.: 70 - */ public function getPriority(): int { return 11; } |