1
|
|
|
<?php |
2
|
|
|
declare(strict_types=1); |
3
|
|
|
|
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Files_FullTextSearch - Index the content of your files |
7
|
|
|
* |
8
|
|
|
* This file is licensed under the Affero General Public License version 3 or |
9
|
|
|
* later. See the COPYING file. |
10
|
|
|
* |
11
|
|
|
* @author Maxence Lange <[email protected]> |
12
|
|
|
* @copyright 2018 |
13
|
|
|
* @license GNU AGPL version 3 or any later version |
14
|
|
|
* |
15
|
|
|
* This program is free software: you can redistribute it and/or modify |
16
|
|
|
* it under the terms of the GNU Affero General Public License as |
17
|
|
|
* published by the Free Software Foundation, either version 3 of the |
18
|
|
|
* License, or (at your option) any later version. |
19
|
|
|
* |
20
|
|
|
* This program is distributed in the hope that it will be useful, |
21
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
22
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
23
|
|
|
* GNU Affero General Public License for more details. |
24
|
|
|
* |
25
|
|
|
* You should have received a copy of the GNU Affero General Public License |
26
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
27
|
|
|
* |
28
|
|
|
*/ |
29
|
|
|
|
30
|
|
|
|
31
|
|
|
namespace OCA\Files_FullTextSearch\Events; |
32
|
|
|
|
33
|
|
|
|
34
|
|
|
use OCP\AppFramework\QueryException; |
35
|
|
|
use OCP\Comments\CommentsEvent; |
36
|
|
|
use OCP\Comments\ICommentsEventHandler; |
37
|
|
|
|
38
|
|
|
|
39
|
|
|
class FilesCommentsEvents implements ICommentsEventHandler { |
40
|
|
|
|
41
|
|
|
|
42
|
|
|
/** @var FilesEvents */ |
43
|
|
|
private $filesEvents; |
44
|
|
|
|
45
|
|
|
|
46
|
|
|
public function __construct(FilesEvents $filesEvents) { |
47
|
|
|
$this->filesEvents = $filesEvents; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @param CommentsEvent $event |
52
|
|
|
* |
53
|
|
|
* @throws QueryException |
54
|
|
|
*/ |
55
|
|
|
public function handle(CommentsEvent $event) { |
56
|
|
|
if ($event->getComment() |
57
|
|
|
->getObjectType() !== 'files') { |
58
|
|
|
return; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
$eventType = $event->getEvent(); |
62
|
|
|
if ($eventType === CommentsEvent::EVENT_ADD) { |
63
|
|
|
$this->filesEvents->onCommentNew($event); |
64
|
|
|
|
65
|
|
|
return; |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
|