Skip to content

Commit 456aea8

Browse files
authored
Merge pull request #39236 from shdehnavi/refactor_comments_app
2 parents c2e4a7b + 92b75bc commit 456aea8

15 files changed

Lines changed: 68 additions & 134 deletions

apps/comments/lib/Activity/Filter.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,10 @@
2727
use OCP\IURLGenerator;
2828

2929
class Filter implements IFilter {
30-
protected IL10N $l;
31-
protected IURLGenerator $url;
32-
33-
public function __construct(IL10N $l, IURLGenerator $url) {
34-
$this->l = $l;
35-
$this->url = $url;
30+
public function __construct(
31+
protected IL10N $l,
32+
protected IURLGenerator $url,
33+
) {
3634
}
3735

3836
public function getIdentifier(): string {

apps/comments/lib/Activity/Listener.php

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -35,28 +35,14 @@
3535
use OCP\Share\IShareHelper;
3636

3737
class Listener {
38-
protected IManager $activityManager;
39-
protected IUserSession $session;
40-
protected IAppManager $appManager;
41-
protected IMountProviderCollection $mountCollection;
42-
protected IRootFolder $rootFolder;
43-
protected IShareHelper $shareHelper;
44-
45-
/**
46-
* Listener constructor.
47-
*/
48-
public function __construct(IManager $activityManager,
49-
IUserSession $session,
50-
IAppManager $appManager,
51-
IMountProviderCollection $mountCollection,
52-
IRootFolder $rootFolder,
53-
IShareHelper $shareHelper) {
54-
$this->activityManager = $activityManager;
55-
$this->session = $session;
56-
$this->appManager = $appManager;
57-
$this->mountCollection = $mountCollection;
58-
$this->rootFolder = $rootFolder;
59-
$this->shareHelper = $shareHelper;
38+
public function __construct(
39+
protected IManager $activityManager,
40+
protected IUserSession $session,
41+
protected IAppManager $appManager,
42+
protected IMountProviderCollection $mountCollection,
43+
protected IRootFolder $rootFolder,
44+
protected IShareHelper $shareHelper,
45+
) {
6046
}
6147

6248
public function commentEvent(CommentsEvent $event): void {

apps/comments/lib/Activity/Provider.php

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,15 @@
3535
use OCP\L10N\IFactory;
3636

3737
class Provider implements IProvider {
38-
protected IFactory $languageFactory;
3938
protected ?IL10N $l = null;
40-
protected IUrlGenerator $url;
41-
protected ICommentsManager $commentsManager;
42-
protected IUserManager $userManager;
43-
protected IManager $activityManager;
44-
45-
public function __construct(IFactory $languageFactory, IURLGenerator $url, ICommentsManager $commentsManager, IUserManager $userManager, IManager $activityManager) {
46-
$this->languageFactory = $languageFactory;
47-
$this->url = $url;
48-
$this->commentsManager = $commentsManager;
49-
$this->userManager = $userManager;
50-
$this->activityManager = $activityManager;
39+
40+
public function __construct(
41+
protected IFactory $languageFactory,
42+
protected IURLGenerator $url,
43+
protected ICommentsManager $commentsManager,
44+
protected IUserManager $userManager,
45+
protected IManager $activityManager,
46+
) {
5147
}
5248

5349
/**
@@ -168,7 +164,7 @@ protected function parseMessage(IEvent $event): void {
168164
return;
169165
}
170166

171-
$commentId = isset($messageParameters['commentId']) ? $messageParameters['commentId'] : $messageParameters[0];
167+
$commentId = $messageParameters['commentId'] ?? $messageParameters[0];
172168

173169
try {
174170
$comment = $this->commentsManager->get((string) $commentId);

apps/comments/lib/Activity/Setting.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,9 @@
2626
use OCP\IL10N;
2727

2828
class Setting implements ISetting {
29-
protected IL10N $l;
30-
31-
public function __construct(IL10N $l) {
32-
$this->l = $l;
29+
public function __construct(
30+
protected IL10N $l,
31+
) {
3332
}
3433

3534
public function getIdentifier(): string {

apps/comments/lib/Collaboration/CommentersSorter.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,9 @@
2727
use OCP\Comments\ICommentsManager;
2828

2929
class CommentersSorter implements ISorter {
30-
private ICommentsManager $commentsManager;
31-
32-
public function __construct(ICommentsManager $commentsManager) {
33-
$this->commentsManager = $commentsManager;
30+
public function __construct(
31+
private ICommentsManager $commentsManager,
32+
) {
3433
}
3534

3635
public function getId(): string {

apps/comments/lib/Controller/NotificationsController.php

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -43,31 +43,16 @@
4343
*/
4444
#[IgnoreOpenAPI]
4545
class NotificationsController extends Controller {
46-
47-
protected IRootFolder $rootFolder;
48-
protected ICommentsManager $commentsManager;
49-
protected IURLGenerator $urlGenerator;
50-
protected IManager $notificationManager;
51-
protected IUserSession $userSession;
52-
53-
/**
54-
* NotificationsController constructor.
55-
*/
5646
public function __construct(
5747
string $appName,
5848
IRequest $request,
59-
ICommentsManager $commentsManager,
60-
IRootFolder $rootFolder,
61-
IURLGenerator $urlGenerator,
62-
IManager $notificationManager,
63-
IUserSession $userSession
49+
protected ICommentsManager $commentsManager,
50+
protected IRootFolder $rootFolder,
51+
protected IURLGenerator $urlGenerator,
52+
protected IManager $notificationManager,
53+
protected IUserSession $userSession
6454
) {
6555
parent::__construct($appName, $request);
66-
$this->commentsManager = $commentsManager;
67-
$this->rootFolder = $rootFolder;
68-
$this->urlGenerator = $urlGenerator;
69-
$this->notificationManager = $notificationManager;
70-
$this->userSession = $userSession;
7156
}
7257

7358
/**

apps/comments/lib/EventHandler.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,10 @@
3434
* @package OCA\Comments
3535
*/
3636
class EventHandler implements ICommentsEventHandler {
37-
private ActivityListener $activityListener;
38-
private NotificationListener $notificationListener;
39-
40-
public function __construct(ActivityListener $activityListener, NotificationListener $notificationListener) {
41-
$this->activityListener = $activityListener;
42-
$this->notificationListener = $notificationListener;
37+
public function __construct(
38+
private ActivityListener $activityListener,
39+
private NotificationListener $notificationListener,
40+
) {
4341
}
4442

4543
public function handle(CommentsEvent $event): void {

apps/comments/lib/Listener/CommentsEntityEventListener.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,10 @@
3131
use OCP\Files\IRootFolder;
3232

3333
class CommentsEntityEventListener implements IEventListener {
34-
private IRootFolder $rootFolder;
35-
private ?string $userId;
36-
37-
public function __construct(IRootFolder $rootFolder, ?string $userId = null) {
38-
$this->rootFolder = $rootFolder;
39-
$this->userId = $userId;
34+
public function __construct(
35+
private IRootFolder $rootFolder,
36+
private ?string $userId = null,
37+
) {
4038
}
4139

4240
public function handle(Event $event): void {

apps/comments/lib/Listener/LoadSidebarScripts.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,9 @@
3434
use OCP\Util;
3535

3636
class LoadSidebarScripts implements IEventListener {
37-
38-
private ICommentsManager $commentsManager;
39-
40-
public function __construct(ICommentsManager $commentsManager) {
41-
$this->commentsManager = $commentsManager;
37+
public function __construct(
38+
private ICommentsManager $commentsManager,
39+
) {
4240
}
4341

4442
public function handle(Event $event): void {

apps/comments/lib/MaxAutoCompleteResultsInitialState.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,9 @@
3131
use OCP\IConfig;
3232

3333
class MaxAutoCompleteResultsInitialState extends InitialStateProvider {
34-
private IConfig $config;
35-
36-
public function __construct(IConfig $config) {
37-
$this->config = $config;
34+
public function __construct(
35+
private IConfig $config,
36+
) {
3837
}
3938

4039
public function getKey(): string {

0 commit comments

Comments
 (0)