mirror of
https://github.com/nextcloud/server.git
synced 2026-06-09 00:32:29 -04:00
Refactors controllers by using PHP8's constructor property promotion.
Signed-off-by: Faraz Samapoor <f.samapoor@gmail.com>
This commit is contained in:
parent
d820ab2ca8
commit
4bf610ebaf
11 changed files with 64 additions and 175 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue