aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorFaraz Samapoor <f.samapoor@gmail.com>2023-06-04 23:46:27 +0330
committerLouis <6653109+artonge@users.noreply.github.com>2023-06-16 19:29:40 +0200
commit4bf610ebaf52447a678e83d40a98463969e6fd51 (patch)
tree93f2cab7e491ac9f2071e69aa8754b4ab9243ca1 /core
parentd820ab2ca8342d756ec8e0554e180e7f00cc3860 (diff)
downloadnextcloud-server-4bf610ebaf52447a678e83d40a98463969e6fd51.tar.gz
nextcloud-server-4bf610ebaf52447a678e83d40a98463969e6fd51.zip
Refactors controllers by using PHP8's constructor property promotion.
Signed-off-by: Faraz Samapoor <f.samapoor@gmail.com>
Diffstat (limited to 'core')
-rw-r--r--core/Controller/JsController.php7
-rw-r--r--core/Controller/LoginController.php46
-rw-r--r--core/Controller/LostController.php62
-rw-r--r--core/Controller/NavigationController.php10
-rw-r--r--core/Controller/OCSController.php17
-rw-r--r--core/Controller/PreviewController.php15
-rw-r--r--core/Controller/ProfileApiController.php21
-rw-r--r--core/Controller/ProfilePageController.php35
-rw-r--r--core/Controller/RecommendedAppsController.php9
-rw-r--r--core/Controller/ReferenceApiController.php9
-rw-r--r--core/Controller/ReferenceController.php10
11 files changed, 65 insertions, 176 deletions
diff --git a/core/Controller/JsController.php b/core/Controller/JsController.php
index 6b3e7ff2ed2..8a361dae67f 100644
--- a/core/Controller/JsController.php
+++ b/core/Controller/JsController.php
@@ -45,13 +45,14 @@ 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..4c3d07c6cf2 100644
--- a/core/Controller/LoginController.php
+++ b/core/Controller/LoginController.php
@@ -63,44 +63,20 @@ 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) {
+ private IUserManager $userManager,
+ private IConfig $config,
+ private ISession $session,
+ private IUserSession $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..1b773b344af 100644
--- a/core/Controller/LostController.php
+++ b/core/Controller/LostController.php
@@ -73,54 +73,26 @@ 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,
- string $defaultMailAddress,
- IManager $encryptionManager,
- IMailer $mailer,
- LoggerInterface $logger,
- Manager $twoFactorManager,
- IInitialState $initialState,
- IVerificationToken $verificationToken,
- IEventDispatcher $eventDispatcher,
- Limiter $limiter
- ) {
+
+ public function __construct(string $appName,
+ IRequest $request,
+ private IURLGenerator $urlGenerator,
+ private IUserManager $userManager,
+ private Defaults $defaults,
+ private IL10N $l10n,
+ private IConfig $config,
+ string $defaultMailAddress,
+ 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..68a9bf98037 100644
--- a/core/Controller/NavigationController.php
+++ b/core/Controller/NavigationController.php
@@ -30,13 +30,11 @@ 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/OCSController.php b/core/Controller/OCSController.php
index b40776fcfb8..c4ae91b4db1 100644
--- a/core/Controller/OCSController.php
+++ b/core/Controller/OCSController.php
@@ -35,22 +35,13 @@ 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) {
+ 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..d742af20e1d 100644
--- a/core/Controller/PreviewController.php
+++ b/core/Controller/PreviewController.php
@@ -40,21 +40,12 @@ 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
- ) {
+ 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..8fde293d5c9 100644
--- a/core/Controller/ProfileApiController.php
+++ b/core/Controller/ProfileApiController.php
@@ -38,23 +38,12 @@ 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
- ) {
+ public function __construct(IRequest $request,
+ 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..3e9478ba65c 100644
--- a/core/Controller/ProfilePageController.php
+++ b/core/Controller/ProfilePageController.php
@@ -40,33 +40,16 @@ 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,
- IRequest $request,
- IInitialState $initialStateService,
- ProfileManager $profileManager,
- IShareManager $shareManager,
- IUserManager $userManager,
- IUserSession $userSession,
- IUserStatusManager $userStatusManager,
- IEventDispatcher $eventDispatcher
- ) {
+ public function __construct(string $appName,
+ IRequest $request,
+ 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..5c3d71012a7 100644
--- a/core/Controller/RecommendedAppsController.php
+++ b/core/Controller/RecommendedAppsController.php
@@ -33,15 +33,10 @@ 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 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..25d78e153e8 100644
--- a/core/Controller/ReferenceApiController.php
+++ b/core/Controller/ReferenceApiController.php
@@ -30,16 +30,11 @@ 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) {
+ 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..daebd89a947 100644
--- a/core/Controller/ReferenceController.php
+++ b/core/Controller/ReferenceController.php
@@ -36,13 +36,11 @@ 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;
}
/**