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