Refactors controllers by using PHP8's constructor property promotion.
Co-authored-by: Julius Härtl <jus@bitgrid.net> Signed-off-by: Faraz Samapoor <f.samapoor@gmail.com> Signed-off-by: Faraz Samapoor <fsa@adlas.at>
This commit is contained in:
@@ -29,11 +29,12 @@ use OCP\AppFramework\Http\DataResponse;
|
||||
use OCP\IRequest;
|
||||
|
||||
class AttachmentApiController extends ApiController {
|
||||
private $attachmentService;
|
||||
|
||||
public function __construct($appName, IRequest $request, AttachmentService $attachmentService) {
|
||||
public function __construct(
|
||||
$appName,
|
||||
IRequest $request,
|
||||
private AttachmentService $attachmentService,
|
||||
) {
|
||||
parent::__construct($appName, $request);
|
||||
$this->attachmentService = $attachmentService;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -28,13 +28,12 @@ use OCP\AppFramework\Controller;
|
||||
use OCP\IRequest;
|
||||
|
||||
class AttachmentController extends Controller {
|
||||
|
||||
/** @var AttachmentService */
|
||||
private $attachmentService;
|
||||
|
||||
public function __construct($appName, IRequest $request, AttachmentService $attachmentService) {
|
||||
public function __construct(
|
||||
$appName,
|
||||
IRequest $request,
|
||||
private AttachmentService $attachmentService,
|
||||
) {
|
||||
parent::__construct($appName, $request);
|
||||
$this->attachmentService = $attachmentService;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -40,18 +40,16 @@ use Sabre\HTTP\Util;
|
||||
* @package OCA\Deck\Controller
|
||||
*/
|
||||
class BoardApiController extends ApiController {
|
||||
private $boardService;
|
||||
|
||||
/**
|
||||
* @param string $appName
|
||||
* @param IRequest $request
|
||||
* @param BoardService $service
|
||||
* @param $userId
|
||||
*/
|
||||
public function __construct($appName, IRequest $request, BoardService $service, $userId) {
|
||||
public function __construct(
|
||||
$appName,
|
||||
IRequest $request,
|
||||
private BoardService $boardService,
|
||||
private $userId,
|
||||
) {
|
||||
parent::__construct($appName, $request);
|
||||
$this->boardService = $service;
|
||||
$this->userId = $userId;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -33,15 +33,14 @@ use OCP\AppFramework\Http\DataResponse;
|
||||
use OCP\IRequest;
|
||||
|
||||
class BoardController extends ApiController {
|
||||
private $userId;
|
||||
private $boardService;
|
||||
private $permissionService;
|
||||
|
||||
public function __construct($appName, IRequest $request, BoardService $boardService, PermissionService $permissionService, $userId) {
|
||||
public function __construct(
|
||||
$appName,
|
||||
IRequest $request,
|
||||
private BoardService $boardService,
|
||||
private PermissionService $permissionService,
|
||||
private $userId,
|
||||
) {
|
||||
parent::__construct($appName, $request);
|
||||
$this->userId = $userId;
|
||||
$this->boardService = $boardService;
|
||||
$this->permissionService = $permissionService;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -144,7 +143,7 @@ class BoardController extends ApiController {
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @param $aclId
|
||||
* @return \OCP\AppFramework\Db\Entity
|
||||
* @return \OCP\AppFramework\Db\Entity|null
|
||||
*/
|
||||
public function deleteAcl($aclId) {
|
||||
return $this->boardService->deleteAcl($aclId);
|
||||
|
||||
@@ -30,20 +30,13 @@ use OCP\AppFramework\OCSController;
|
||||
use OCP\IRequest;
|
||||
|
||||
class BoardImportApiController extends OCSController {
|
||||
/** @var BoardImportService */
|
||||
private $boardImportService;
|
||||
/** @var string */
|
||||
private $userId;
|
||||
|
||||
public function __construct(
|
||||
string $appName,
|
||||
IRequest $request,
|
||||
BoardImportService $boardImportService,
|
||||
string $userId
|
||||
private BoardImportService $boardImportService,
|
||||
private string $userId,
|
||||
) {
|
||||
parent::__construct($appName, $request);
|
||||
$this->boardImportService = $boardImportService;
|
||||
$this->userId = $userId;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -38,21 +38,22 @@ use OCP\IRequest;
|
||||
* @package OCA\Deck\Controller
|
||||
*/
|
||||
class CardApiController extends ApiController {
|
||||
private $cardService;
|
||||
private $userId;
|
||||
private $assignmentService;
|
||||
|
||||
/**
|
||||
* @param string $appName
|
||||
* @param IRequest $request
|
||||
* @param CardService $cardService
|
||||
* @param AssignmentService $assignmentService
|
||||
* @param $userId
|
||||
*/
|
||||
public function __construct($appName, IRequest $request, CardService $cardService, AssignmentService $assignmentService, $userId) {
|
||||
public function __construct(
|
||||
string $appName,
|
||||
IRequest $request,
|
||||
private CardService $cardService,
|
||||
private AssignmentService $assignmentService,
|
||||
private $userId,
|
||||
) {
|
||||
parent::__construct($appName, $request);
|
||||
$this->cardService = $cardService;
|
||||
$this->userId = $userId;
|
||||
$this->assignmentService = $assignmentService;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -29,15 +29,14 @@ use OCP\AppFramework\Controller;
|
||||
use OCP\IRequest;
|
||||
|
||||
class CardController extends Controller {
|
||||
private $userId;
|
||||
private $cardService;
|
||||
private $assignmentService;
|
||||
|
||||
public function __construct($appName, IRequest $request, CardService $cardService, AssignmentService $assignmentService, $userId) {
|
||||
public function __construct(
|
||||
$appName,
|
||||
IRequest $request,
|
||||
private CardService $cardService,
|
||||
private AssignmentService $assignmentService,
|
||||
private $userId,
|
||||
) {
|
||||
parent::__construct($appName, $request);
|
||||
$this->userId = $userId;
|
||||
$this->cardService = $cardService;
|
||||
$this->assignmentService = $assignmentService;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -31,18 +31,15 @@ use OCP\AppFramework\OCSController;
|
||||
use OCP\IRequest;
|
||||
|
||||
class CommentsApiController extends OCSController {
|
||||
|
||||
/** @var CommentService */
|
||||
private $commentService;
|
||||
|
||||
public function __construct(
|
||||
string $appName,
|
||||
IRequest $request,
|
||||
CommentService $commentService,
|
||||
string $corsMethods = 'PUT, POST, GET, DELETE, PATCH', string $corsAllowedHeaders = 'Authorization, Content-Type, Accept', int $corsMaxAge = 1728000
|
||||
private CommentService $commentService,
|
||||
string $corsMethods = 'PUT, POST, GET, DELETE, PATCH',
|
||||
string $corsAllowedHeaders = 'Authorization, Content-Type, Accept',
|
||||
int $corsMaxAge = 1728000,
|
||||
) {
|
||||
parent::__construct($appName, $request, $corsMethods, $corsAllowedHeaders, $corsMaxAge);
|
||||
$this->commentService = $commentService;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -30,16 +30,12 @@ use OCP\AppFramework\OCSController;
|
||||
use OCP\IRequest;
|
||||
|
||||
class ConfigController extends OCSController {
|
||||
private $configService;
|
||||
|
||||
public function __construct(
|
||||
$AppName,
|
||||
IRequest $request,
|
||||
ConfigService $configService
|
||||
private ConfigService $configService,
|
||||
) {
|
||||
parent::__construct($AppName, $request);
|
||||
|
||||
$this->configService = $configService;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -35,19 +35,16 @@ use OCP\IRequest;
|
||||
* @package OCA\Deck\Controller
|
||||
*/
|
||||
class LabelApiController extends ApiController {
|
||||
private $labelService;
|
||||
private $userId;
|
||||
|
||||
/**
|
||||
* @param string $appName
|
||||
* @param IRequest $request
|
||||
* @param LabelService $labelService
|
||||
* @param $userId
|
||||
*/
|
||||
public function __construct($appName, IRequest $request, LabelService $labelService, $userId) {
|
||||
public function __construct(
|
||||
$appName,
|
||||
IRequest $request,
|
||||
private LabelService $labelService,
|
||||
private $userId,
|
||||
) {
|
||||
parent::__construct($appName, $request);
|
||||
$this->labelService = $labelService;
|
||||
$this->userId = $userId;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -28,11 +28,12 @@ use OCP\AppFramework\Controller;
|
||||
use OCP\IRequest;
|
||||
|
||||
class LabelController extends Controller {
|
||||
private $labelService;
|
||||
|
||||
public function __construct($appName, IRequest $request, LabelService $labelService) {
|
||||
public function __construct(
|
||||
$appName,
|
||||
IRequest $request,
|
||||
private LabelService $labelService,
|
||||
) {
|
||||
parent::__construct($appName, $request);
|
||||
$this->labelService = $labelService;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -32,17 +32,13 @@ use OCP\AppFramework\OCSController;
|
||||
use OCP\IRequest;
|
||||
|
||||
class OverviewApiController extends OCSController {
|
||||
|
||||
/** @var OverviewService */
|
||||
private $dashboardService;
|
||||
|
||||
/** @var string */
|
||||
private $userId;
|
||||
|
||||
public function __construct($appName, IRequest $request, OverviewService $dashboardService, $userId) {
|
||||
public function __construct(
|
||||
$appName,
|
||||
IRequest $request,
|
||||
private OverviewService $dashboardService,
|
||||
private $userId,
|
||||
) {
|
||||
parent::__construct($appName, $request);
|
||||
$this->dashboardService = $dashboardService;
|
||||
$this->userId = $userId;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -44,37 +44,23 @@ use OCP\IRequest;
|
||||
use OCP\IURLGenerator;
|
||||
|
||||
class PageController extends Controller {
|
||||
private PermissionService $permissionService;
|
||||
private IInitialStateService $initialState;
|
||||
private ConfigService $configService;
|
||||
private IEventDispatcher $eventDispatcher;
|
||||
private CardMapper $cardMapper;
|
||||
private IURLGenerator $urlGenerator;
|
||||
private CardService $cardService;
|
||||
private IConfig $config;
|
||||
|
||||
public function __construct(
|
||||
string $AppName,
|
||||
IRequest $request,
|
||||
PermissionService $permissionService,
|
||||
private PermissionService $permissionService,
|
||||
IInitialStateService $initialStateService,
|
||||
ConfigService $configService,
|
||||
IEventDispatcher $eventDispatcher,
|
||||
CardMapper $cardMapper,
|
||||
IURLGenerator $urlGenerator,
|
||||
CardService $cardService,
|
||||
IConfig $config
|
||||
private ConfigService $configService,
|
||||
private IEventDispatcher $eventDispatcher,
|
||||
private CardMapper $cardMapper,
|
||||
private IURLGenerator $urlGenerator,
|
||||
private CardService $cardService,
|
||||
private IConfig $config,
|
||||
) {
|
||||
parent::__construct($AppName, $request);
|
||||
|
||||
$this->permissionService = $permissionService;
|
||||
$this->initialState = $initialStateService;
|
||||
$this->configService = $configService;
|
||||
$this->eventDispatcher = $eventDispatcher;
|
||||
$this->cardMapper = $cardMapper;
|
||||
$this->urlGenerator = $urlGenerator;
|
||||
$this->cardService = $cardService;
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -34,15 +34,12 @@ use OCP\AppFramework\OCSController;
|
||||
use OCP\IRequest;
|
||||
|
||||
class SearchController extends OCSController {
|
||||
|
||||
/**
|
||||
* @var SearchService
|
||||
*/
|
||||
private $searchService;
|
||||
|
||||
public function __construct(string $appName, IRequest $request, SearchService $searchService) {
|
||||
public function __construct(
|
||||
string $appName,
|
||||
IRequest $request,
|
||||
private SearchService $searchService,
|
||||
) {
|
||||
parent::__construct($appName, $request);
|
||||
$this->searchService = $searchService;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -34,20 +34,13 @@ use OCP\AppFramework\OCSController;
|
||||
use OCP\IRequest;
|
||||
|
||||
class SessionController extends OCSController {
|
||||
private SessionService $sessionService;
|
||||
private PermissionService $permissionService;
|
||||
private BoardMapper $boardMapper;
|
||||
|
||||
public function __construct($appName,
|
||||
IRequest $request,
|
||||
SessionService $sessionService,
|
||||
PermissionService $permissionService,
|
||||
BoardMapper $boardMapper
|
||||
private SessionService $sessionService,
|
||||
private PermissionService $permissionService,
|
||||
private BoardMapper $boardMapper,
|
||||
) {
|
||||
parent::__construct($appName, $request);
|
||||
$this->sessionService = $sessionService;
|
||||
$this->permissionService = $permissionService;
|
||||
$this->boardMapper = $boardMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -39,18 +39,16 @@ use Sabre\HTTP\Util;
|
||||
* @package OCA\Deck\Controller
|
||||
*/
|
||||
class StackApiController extends ApiController {
|
||||
private $boardService;
|
||||
private $stackService;
|
||||
|
||||
/**
|
||||
* @param string $appName
|
||||
* @param IRequest $request
|
||||
* @param StackService $stackService
|
||||
*/
|
||||
public function __construct($appName, IRequest $request, StackService $stackService, BoardService $boardService) {
|
||||
public function __construct(
|
||||
$appName,
|
||||
IRequest $request,
|
||||
private StackService $stackService,
|
||||
private BoardService $boardService,
|
||||
) {
|
||||
parent::__construct($appName, $request);
|
||||
$this->stackService = $stackService;
|
||||
$this->boardService = $boardService;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -30,12 +30,13 @@ use OCP\AppFramework\Controller;
|
||||
use OCP\IRequest;
|
||||
|
||||
class StackController extends Controller {
|
||||
private $userId;
|
||||
private $stackService;
|
||||
public function __construct($appName, IRequest $request, StackService $stackService, $userId) {
|
||||
public function __construct(
|
||||
string $appName,
|
||||
IRequest $request,
|
||||
private StackService $stackService,
|
||||
private $userId,
|
||||
) {
|
||||
parent::__construct($appName, $request);
|
||||
$this->userId = $userId;
|
||||
$this->stackService = $stackService;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user