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:
Faraz Samapoor
2023-07-14 15:41:25 +03:30
parent 90d051f8e4
commit 559579fbd9
17 changed files with 91 additions and 139 deletions

View File

@@ -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;
}
/**

View File

@@ -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;
}
/**

View File

@@ -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;
}
/**

View File

@@ -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);

View File

@@ -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;
}
/**

View File

@@ -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;
}
/**

View File

@@ -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;
}
/**

View File

@@ -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;
}
/**

View File

@@ -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;
}
/**

View File

@@ -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;
}
/**

View File

@@ -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;
}
/**

View File

@@ -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;
}
/**

View File

@@ -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;
}
/**

View File

@@ -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;
}
/**

View File

@@ -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;
}
/**

View File

@@ -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;
}
/**

View File

@@ -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;
}
/**