Skip to content

Commit e9097c2

Browse files
committed
Move over comments to the new event
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
1 parent 17bf174 commit e9097c2

File tree

4 files changed

+51
-8
lines changed

4 files changed

+51
-8
lines changed

apps/comments/composer/composer/autoload_classmap.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
'OCA\\Comments\\Controller\\Notifications' => $baseDir . '/../lib/Controller/Notifications.php',
1616
'OCA\\Comments\\EventHandler' => $baseDir . '/../lib/EventHandler.php',
1717
'OCA\\Comments\\JSSettingsHelper' => $baseDir . '/../lib/JSSettingsHelper.php',
18+
'OCA\\Comments\\Listener\\LoadAdditionalScripts' => $baseDir . '/../lib/Listener/LoadAdditionalScripts.php',
1819
'OCA\\Comments\\Notification\\Listener' => $baseDir . '/../lib/Notification/Listener.php',
1920
'OCA\\Comments\\Notification\\Notifier' => $baseDir . '/../lib/Notification/Notifier.php',
2021
'OCA\\Comments\\Search\\Provider' => $baseDir . '/../lib/Search/Provider.php',

apps/comments/composer/composer/autoload_static.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class ComposerStaticInitComments
3030
'OCA\\Comments\\Controller\\Notifications' => __DIR__ . '/..' . '/../lib/Controller/Notifications.php',
3131
'OCA\\Comments\\EventHandler' => __DIR__ . '/..' . '/../lib/EventHandler.php',
3232
'OCA\\Comments\\JSSettingsHelper' => __DIR__ . '/..' . '/../lib/JSSettingsHelper.php',
33+
'OCA\\Comments\\Listener\\LoadAdditionalScripts' => __DIR__ . '/..' . '/../lib/Listener/LoadAdditionalScripts.php',
3334
'OCA\\Comments\\Notification\\Listener' => __DIR__ . '/..' . '/../lib/Notification/Listener.php',
3435
'OCA\\Comments\\Notification\\Notifier' => __DIR__ . '/..' . '/../lib/Notification/Notifier.php',
3536
'OCA\\Comments\\Search\\Provider' => __DIR__ . '/..' . '/../lib/Search/Provider.php',

apps/comments/lib/AppInfo/Application.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,13 @@
2626
use OCA\Comments\Controller\Notifications;
2727
use OCA\Comments\EventHandler;
2828
use OCA\Comments\JSSettingsHelper;
29+
use OCA\Comments\Listener\LoadAdditionalScripts;
2930
use OCA\Comments\Notification\Notifier;
3031
use OCA\Comments\Search\Provider;
32+
use OCA\Files\Event\LoadAdditionalScriptsEvent;
3133
use OCP\AppFramework\App;
3234
use OCP\Comments\CommentsEntityEvent;
35+
use OCP\EventDispatcher\IEventDispatcher;
3336
use OCP\Util;
3437
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
3538

@@ -49,21 +52,18 @@ public function register() {
4952
$server = $this->getContainer()->getServer();
5053

5154
$dispatcher = $server->getEventDispatcher();
52-
$this->registerSidebarScripts($dispatcher);
55+
/** @var IEventDispatcher $newDispatcher */
56+
$newDispatcher = $server->query(IEventDispatcher::class);
57+
$this->registerSidebarScripts($newDispatcher);
5358
$this->registerDavEntity($dispatcher);
5459
$this->registerNotifier();
5560
$this->registerCommentsEventHandler();
5661

5762
$server->getSearch()->registerProvider(Provider::class, ['apps' => ['files']]);
5863
}
5964

60-
protected function registerSidebarScripts(EventDispatcherInterface $dispatcher) {
61-
$dispatcher->addListener(
62-
'OCA\Files::loadAdditionalScripts',
63-
function() {
64-
Util::addScript('comments', 'comments');
65-
}
66-
);
65+
protected function registerSidebarScripts(IEventDispatcher $dispatcher) {
66+
$dispatcher->addServiceListener(LoadAdditionalScriptsEvent::class, LoadAdditionalScripts::class);
6767
}
6868

6969
protected function registerDavEntity(EventDispatcherInterface $dispatcher) {
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
declare(strict_types=1);
3+
/**
4+
* @copyright Copyright (c) 2019, Roeland Jago Douma <roeland@famdouma.nl>
5+
*
6+
* @author Roeland Jago Douma <roeland@famdouma.nl>
7+
*
8+
* @license GNU AGPL version 3 or any later version
9+
*
10+
* This program is free software: you can redistribute it and/or modify
11+
* it under the terms of the GNU Affero General Public License as
12+
* published by the Free Software Foundation, either version 3 of the
13+
* License, or (at your option) any later version.
14+
*
15+
* This program is distributed in the hope that it will be useful,
16+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18+
* GNU Affero General Public License for more details.
19+
*
20+
* You should have received a copy of the GNU Affero General Public License
21+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
22+
*
23+
*/
24+
25+
namespace OCA\Comments\Listener;
26+
27+
use OCA\Files\Event\LoadAdditionalScriptsEvent;
28+
use OCP\EventDispatcher\Event;
29+
use OCP\EventDispatcher\IEventListener;
30+
use OCP\Util;
31+
32+
class LoadAdditionalScripts implements IEventListener {
33+
public function handle(Event $event): void {
34+
if (!($event instanceof LoadAdditionalScriptsEvent)) {
35+
return;
36+
}
37+
38+
Util::addScript('comments', 'comments');
39+
}
40+
41+
}

0 commit comments

Comments
 (0)