aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorLouis <6653109+artonge@users.noreply.github.com>2023-06-19 12:22:07 +0200
committerGitHub <noreply@github.com>2023-06-19 12:22:07 +0200
commitceee417d2c48153d25460405c55594f8fdbb6b80 (patch)
treec1a7536c39d9de722d5cb7264c9faf018beb99ea /core
parentb33cbecb47f4caf7dc5db3c3bfeb208eea0fba98 (diff)
parentd64aa85b0464933bd2dc25a56c0569c6dad6af19 (diff)
downloadnextcloud-server-ceee417d2c48153d25460405c55594f8fdbb6b80.tar.gz
nextcloud-server-ceee417d2c48153d25460405c55594f8fdbb6b80.zip
Merge pull request #38637 from fsamapoor/constructor_property_promotion_part2
[2/3] Refactors /core controllers using constructor property promotion.
Diffstat (limited to 'core')
-rw-r--r--core/Controller/JsController.php9
-rw-r--r--core/Controller/LoginController.php53
-rw-r--r--core/Controller/LostController.php52
-rw-r--r--core/Controller/NavigationController.php12
-rw-r--r--core/Controller/OCJSController.php28
-rw-r--r--core/Controller/OCSController.php23
-rw-r--r--core/Controller/PreviewController.php19
-rw-r--r--core/Controller/ProfileApiController.php17
-rw-r--r--core/Controller/ProfilePageController.php31
-rw-r--r--core/Controller/RecommendedAppsController.php13
-rw-r--r--core/Controller/ReferenceApiController.php15
-rw-r--r--core/Controller/ReferenceController.php12
12 files changed, 98 insertions, 186 deletions
diff --git a/core/Controller/JsController.php b/core/Controller/JsController.php
index 6b3e7ff2ed2..0ad78d5f87f 100644
--- a/core/Controller/JsController.php
+++ b/core/Controller/JsController.php
@@ -45,13 +45,16 @@ use OCP\IRequest;
class JsController extends Controller {
protected IAppData $appData;
- protected ITimeFactory $timeFactory;
- public function __construct($appName, IRequest $request, Factory $appDataFactory, ITimeFactory $timeFactory) {
+ public function __construct(
+ string $appName,
+ IRequest $request,
+ Factory $appDataFactory,
+ protected ITimeFactory $timeFactory,
+ ) {
parent::__construct($appName, $request);
$this->appData = $appDataFactory->get('js');
- $this->timeFactory = $timeFactory;
}
/**
diff --git a/core/Controller/LoginController.php b/core/Controller/LoginController.php
index 9c64204b898..1bee366b00f 100644
--- a/core/Controller/LoginController.php
+++ b/core/Controller/LoginController.php
@@ -55,7 +55,6 @@ use OCP\ISession;
use OCP\IURLGenerator;
use OCP\IUser;
use OCP\IUserManager;
-use OCP\IUserSession;
use OCP\Notification\IManager;
use OCP\Util;
@@ -63,44 +62,22 @@ class LoginController extends Controller {
public const LOGIN_MSG_INVALIDPASSWORD = 'invalidpassword';
public const LOGIN_MSG_USERDISABLED = 'userdisabled';
- private IUserManager $userManager;
- private IConfig $config;
- private ISession $session;
- /** @var Session */
- private $userSession;
- private IURLGenerator $urlGenerator;
- private Defaults $defaults;
- private Throttler $throttler;
- private IInitialStateService $initialStateService;
- private WebAuthnManager $webAuthnManager;
- private IManager $manager;
- private IL10N $l10n;
-
- public function __construct(?string $appName,
- IRequest $request,
- IUserManager $userManager,
- IConfig $config,
- ISession $session,
- IUserSession $userSession,
- IURLGenerator $urlGenerator,
- Defaults $defaults,
- Throttler $throttler,
- IInitialStateService $initialStateService,
- WebAuthnManager $webAuthnManager,
- IManager $manager,
- IL10N $l10n) {
+ public function __construct(
+ ?string $appName,
+ IRequest $request,
+ private IUserManager $userManager,
+ private IConfig $config,
+ private ISession $session,
+ private Session $userSession,
+ private IURLGenerator $urlGenerator,
+ private Defaults $defaults,
+ private Throttler $throttler,
+ private IInitialStateService $initialStateService,
+ private WebAuthnManager $webAuthnManager,
+ private IManager $manager,
+ private IL10N $l10n,
+ ) {
parent::__construct($appName, $request);
- $this->userManager = $userManager;
- $this->config = $config;
- $this->session = $session;
- $this->userSession = $userSession;
- $this->urlGenerator = $urlGenerator;
- $this->defaults = $defaults;
- $this->throttler = $throttler;
- $this->initialStateService = $initialStateService;
- $this->webAuthnManager = $webAuthnManager;
- $this->manager = $manager;
- $this->l10n = $l10n;
}
/**
diff --git a/core/Controller/LostController.php b/core/Controller/LostController.php
index 127c6310f6b..7de93b7107a 100644
--- a/core/Controller/LostController.php
+++ b/core/Controller/LostController.php
@@ -73,54 +73,28 @@ use function reset;
* @package OC\Core\Controller
*/
class LostController extends Controller {
- protected IURLGenerator $urlGenerator;
- protected IUserManager $userManager;
- protected Defaults $defaults;
- protected IL10N $l10n;
protected string $from;
- protected IManager $encryptionManager;
- protected IConfig $config;
- protected IMailer $mailer;
- private LoggerInterface $logger;
- private Manager $twoFactorManager;
- private IInitialState $initialState;
- private IVerificationToken $verificationToken;
- private IEventDispatcher $eventDispatcher;
- private Limiter $limiter;
public function __construct(
string $appName,
IRequest $request,
- IURLGenerator $urlGenerator,
- IUserManager $userManager,
- Defaults $defaults,
- IL10N $l10n,
- IConfig $config,
+ private IURLGenerator $urlGenerator,
+ private IUserManager $userManager,
+ private Defaults $defaults,
+ private IL10N $l10n,
+ private IConfig $config,
string $defaultMailAddress,
- IManager $encryptionManager,
- IMailer $mailer,
- LoggerInterface $logger,
- Manager $twoFactorManager,
- IInitialState $initialState,
- IVerificationToken $verificationToken,
- IEventDispatcher $eventDispatcher,
- Limiter $limiter
+ private IManager $encryptionManager,
+ private IMailer $mailer,
+ private LoggerInterface $logger,
+ private Manager $twoFactorManager,
+ private IInitialState $initialState,
+ private IVerificationToken $verificationToken,
+ private IEventDispatcher $eventDispatcher,
+ private Limiter $limiter,
) {
parent::__construct($appName, $request);
- $this->urlGenerator = $urlGenerator;
- $this->userManager = $userManager;
- $this->defaults = $defaults;
- $this->l10n = $l10n;
$this->from = $defaultMailAddress;
- $this->encryptionManager = $encryptionManager;
- $this->config = $config;
- $this->mailer = $mailer;
- $this->logger = $logger;
- $this->twoFactorManager = $twoFactorManager;
- $this->initialState = $initialState;
- $this->verificationToken = $verificationToken;
- $this->eventDispatcher = $eventDispatcher;
- $this->limiter = $limiter;
}
/**
diff --git a/core/Controller/NavigationController.php b/core/Controller/NavigationController.php
index a1c3f917fe3..62c4dd98756 100644
--- a/core/Controller/NavigationController.php
+++ b/core/Controller/NavigationController.php
@@ -30,13 +30,13 @@ use OCP\IRequest;
use OCP\IURLGenerator;
class NavigationController extends OCSController {
- private INavigationManager $navigationManager;
- private IURLGenerator $urlGenerator;
-
- public function __construct(string $appName, IRequest $request, INavigationManager $navigationManager, IURLGenerator $urlGenerator) {
+ public function __construct(
+ string $appName,
+ IRequest $request,
+ private INavigationManager $navigationManager,
+ private IURLGenerator $urlGenerator,
+ ) {
parent::__construct($appName, $request);
- $this->navigationManager = $navigationManager;
- $this->urlGenerator = $urlGenerator;
}
/**
diff --git a/core/Controller/OCJSController.php b/core/Controller/OCJSController.php
index fa13f21607c..48bd842e6e2 100644
--- a/core/Controller/OCJSController.php
+++ b/core/Controller/OCJSController.php
@@ -47,19 +47,21 @@ use OCP\L10N\IFactory;
class OCJSController extends Controller {
private JSConfigHelper $helper;
- public function __construct(string $appName,
- IRequest $request,
- IFactory $l10nFactory,
- Defaults $defaults,
- IAppManager $appManager,
- ISession $session,
- IUserSession $userSession,
- IConfig $config,
- IGroupManager $groupManager,
- IniGetWrapper $iniWrapper,
- IURLGenerator $urlGenerator,
- CapabilitiesManager $capabilitiesManager,
- IInitialStateService $initialStateService) {
+ public function __construct(
+ string $appName,
+ IRequest $request,
+ IFactory $l10nFactory,
+ Defaults $defaults,
+ IAppManager $appManager,
+ ISession $session,
+ IUserSession $userSession,
+ IConfig $config,
+ IGroupManager $groupManager,
+ IniGetWrapper $iniWrapper,
+ IURLGenerator $urlGenerator,
+ CapabilitiesManager $capabilitiesManager,
+ IInitialStateService $initialStateService,
+ ) {
parent::__construct($appName, $request);
$this->helper = new JSConfigHelper(
diff --git a/core/Controller/OCSController.php b/core/Controller/OCSController.php
index b40776fcfb8..036cdfc2d60 100644
--- a/core/Controller/OCSController.php
+++ b/core/Controller/OCSController.php
@@ -35,22 +35,15 @@ use OCP\IUserManager;
use OCP\IUserSession;
class OCSController extends \OCP\AppFramework\OCSController {
- private CapabilitiesManager $capabilitiesManager;
- private IUserSession $userSession;
- private IUserManager $userManager;
- private Manager $keyManager;
-
- public function __construct(string $appName,
- IRequest $request,
- CapabilitiesManager $capabilitiesManager,
- IUserSession $userSession,
- IUserManager $userManager,
- Manager $keyManager) {
+ public function __construct(
+ string $appName,
+ IRequest $request,
+ private CapabilitiesManager $capabilitiesManager,
+ private IUserSession $userSession,
+ private IUserManager $userManager,
+ private Manager $keyManager,
+ ) {
parent::__construct($appName, $request);
- $this->capabilitiesManager = $capabilitiesManager;
- $this->userSession = $userSession;
- $this->userManager = $userManager;
- $this->keyManager = $keyManager;
}
/**
diff --git a/core/Controller/PreviewController.php b/core/Controller/PreviewController.php
index 118f1b47752..38373e2d147 100644
--- a/core/Controller/PreviewController.php
+++ b/core/Controller/PreviewController.php
@@ -40,21 +40,14 @@ use OCP\IPreview;
use OCP\IRequest;
class PreviewController extends Controller {
- private ?string $userId;
- private IRootFolder $root;
- private IPreview $preview;
-
- public function __construct(string $appName,
- IRequest $request,
- IPreview $preview,
- IRootFolder $root,
- ?string $userId
+ public function __construct(
+ string $appName,
+ IRequest $request,
+ private IPreview $preview,
+ private IRootFolder $root,
+ private ?string $userId,
) {
parent::__construct($appName, $request);
-
- $this->preview = $preview;
- $this->root = $root;
- $this->userId = $userId;
}
/**
diff --git a/core/Controller/ProfileApiController.php b/core/Controller/ProfileApiController.php
index 6d1b856929a..e66d4f21c2b 100644
--- a/core/Controller/ProfileApiController.php
+++ b/core/Controller/ProfileApiController.php
@@ -38,23 +38,14 @@ use OCP\IUserSession;
use OC\Profile\ProfileManager;
class ProfileApiController extends OCSController {
- private ProfileConfigMapper $configMapper;
- private ProfileManager $profileManager;
- private IUserManager $userManager;
- private IUserSession $userSession;
-
public function __construct(
IRequest $request,
- ProfileConfigMapper $configMapper,
- ProfileManager $profileManager,
- IUserManager $userManager,
- IUserSession $userSession
+ private ProfileConfigMapper $configMapper,
+ private ProfileManager $profileManager,
+ private IUserManager $userManager,
+ private IUserSession $userSession,
) {
parent::__construct('core', $request);
- $this->configMapper = $configMapper;
- $this->profileManager = $profileManager;
- $this->userManager = $userManager;
- $this->userSession = $userSession;
}
/**
diff --git a/core/Controller/ProfilePageController.php b/core/Controller/ProfilePageController.php
index 4b710911482..23dbf104b6b 100644
--- a/core/Controller/ProfilePageController.php
+++ b/core/Controller/ProfilePageController.php
@@ -40,33 +40,18 @@ use OCP\UserStatus\IManager as IUserStatusManager;
use OCP\EventDispatcher\IEventDispatcher;
class ProfilePageController extends Controller {
- private IInitialState $initialStateService;
- private ProfileManager $profileManager;
- private IShareManager $shareManager;
- private IUserManager $userManager;
- private IUserSession $userSession;
- private IUserStatusManager $userStatusManager;
- private IEventDispatcher $eventDispatcher;
-
public function __construct(
- $appName,
+ string $appName,
IRequest $request,
- IInitialState $initialStateService,
- ProfileManager $profileManager,
- IShareManager $shareManager,
- IUserManager $userManager,
- IUserSession $userSession,
- IUserStatusManager $userStatusManager,
- IEventDispatcher $eventDispatcher
+ private IInitialState $initialStateService,
+ private ProfileManager $profileManager,
+ private IShareManager $shareManager,
+ private IUserManager $userManager,
+ private IUserSession $userSession,
+ private IUserStatusManager $userStatusManager,
+ private IEventDispatcher $eventDispatcher,
) {
parent::__construct($appName, $request);
- $this->initialStateService = $initialStateService;
- $this->profileManager = $profileManager;
- $this->shareManager = $shareManager;
- $this->userManager = $userManager;
- $this->userSession = $userSession;
- $this->userStatusManager = $userStatusManager;
- $this->eventDispatcher = $eventDispatcher;
}
/**
diff --git a/core/Controller/RecommendedAppsController.php b/core/Controller/RecommendedAppsController.php
index 5c73f3c5f5e..5765b946613 100644
--- a/core/Controller/RecommendedAppsController.php
+++ b/core/Controller/RecommendedAppsController.php
@@ -33,15 +33,12 @@ use OCP\IRequest;
use OCP\IURLGenerator;
class RecommendedAppsController extends Controller {
- public IURLGenerator $urlGenerator;
- private IInitialStateService $initialStateService;
-
- public function __construct(IRequest $request,
- IURLGenerator $urlGenerator,
- IInitialStateService $initialStateService) {
+ public function __construct(
+ IRequest $request,
+ public IURLGenerator $urlGenerator,
+ private IInitialStateService $initialStateService,
+ ) {
parent::__construct('core', $request);
- $this->urlGenerator = $urlGenerator;
- $this->initialStateService = $initialStateService;
}
/**
diff --git a/core/Controller/ReferenceApiController.php b/core/Controller/ReferenceApiController.php
index 6aba56d7e77..3df2e41c2a9 100644
--- a/core/Controller/ReferenceApiController.php
+++ b/core/Controller/ReferenceApiController.php
@@ -30,16 +30,13 @@ use OCP\Collaboration\Reference\IReferenceManager;
use OCP\IRequest;
class ReferenceApiController extends \OCP\AppFramework\OCSController {
- private IReferenceManager $referenceManager;
- private ?string $userId;
-
- public function __construct(string $appName,
- IRequest $request,
- IReferenceManager $referenceManager,
- ?string $userId) {
+ public function __construct(
+ string $appName,
+ IRequest $request,
+ private IReferenceManager $referenceManager,
+ private ?string $userId,
+ ) {
parent::__construct($appName, $request);
- $this->referenceManager = $referenceManager;
- $this->userId = $userId;
}
/**
diff --git a/core/Controller/ReferenceController.php b/core/Controller/ReferenceController.php
index ae6aeeaa6cc..a8a489aeeab 100644
--- a/core/Controller/ReferenceController.php
+++ b/core/Controller/ReferenceController.php
@@ -36,13 +36,13 @@ use OCP\Files\NotPermittedException;
use OCP\IRequest;
class ReferenceController extends Controller {
- private IReferenceManager $referenceManager;
- private IAppDataFactory $appDataFactory;
-
- public function __construct(string $appName, IRequest $request, IReferenceManager $referenceManager, IAppDataFactory $appDataFactory) {
+ public function __construct(
+ string $appName,
+ IRequest $request,
+ private IReferenceManager $referenceManager,
+ private IAppDataFactory $appDataFactory,
+ ) {
parent::__construct($appName, $request);
- $this->referenceManager = $referenceManager;
- $this->appDataFactory = $appDataFactory;
}
/**