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\AppInfo; |
32
|
|
|
|
33
|
|
|
|
34
|
|
|
use Closure; |
35
|
|
|
use OCA\Files_FullTextSearch\Hooks\FilesHooks; |
36
|
|
|
use OCA\FullTextSearch\Service\IndexService; |
37
|
|
|
use OCA\FullTextSearch\Service\ProviderService; |
38
|
|
|
use OCA\FullTextSearch\Service\SearchService; |
39
|
|
|
use OCP\AppFramework\App; |
40
|
|
|
use OCP\AppFramework\Bootstrap\IBootContext; |
41
|
|
|
use OCP\AppFramework\Bootstrap\IBootstrap; |
42
|
|
|
use OCP\AppFramework\Bootstrap\IRegistrationContext; |
43
|
|
|
use OCP\IServerContainer; |
44
|
|
|
use OCP\Util; |
45
|
|
|
use Throwable; |
46
|
|
|
|
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Class Application |
50
|
|
|
* |
51
|
|
|
* @package OCA\Files_FullTextSearch\AppInfo |
52
|
|
|
*/ |
53
|
|
|
class Application extends App implements IBootstrap { |
54
|
|
|
|
55
|
|
|
|
56
|
|
|
const APP_NAME = 'files_fulltextsearch'; |
57
|
|
|
|
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Application constructor. |
61
|
|
|
* |
62
|
|
|
* @param array $params |
63
|
|
|
*/ |
64
|
|
|
public function __construct(array $params = []) { |
65
|
|
|
parent::__construct(self::APP_NAME, $params); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @param IRegistrationContext $context |
71
|
|
|
*/ |
72
|
|
|
public function register(IRegistrationContext $context): void { |
73
|
|
|
// TODO: check that files' event are migrated to the last version of event dispatcher |
74
|
|
|
// $context->registerEventListener(); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* @param IBootContext $context |
80
|
|
|
* |
81
|
|
|
* @throws Throwable |
82
|
|
|
*/ |
83
|
|
|
public function boot(IBootContext $context): void { |
84
|
|
|
$context->injectFn(Closure::fromCallable([$this, 'registerHooks'])); |
85
|
|
|
$context->injectFn(Closure::fromCallable([$this, 'registerCommentsHooks'])); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* Register Hooks |
91
|
|
|
* |
92
|
|
|
* @param IServerContainer $container |
93
|
|
|
*/ |
94
|
|
|
public function registerHooks(IServerContainer $container) { |
95
|
|
|
Util::connectHook('OC_Filesystem', 'post_create', FilesHooks::class, 'onNewFile'); |
96
|
|
|
Util::connectHook('OC_Filesystem', 'post_update', FilesHooks::class, 'onFileUpdate'); |
97
|
|
|
Util::connectHook('OC_Filesystem', 'post_rename', FilesHooks::class, 'onFileRename'); |
98
|
|
|
Util::connectHook('OC_Filesystem', 'delete', FilesHooks::class, 'onFileTrash'); |
99
|
|
|
Util::connectHook( |
100
|
|
|
'\OCA\Files_Trashbin\Trashbin', 'post_restore', FilesHooks::class, 'onFileRestore' |
101
|
|
|
); |
102
|
|
|
Util::connectHook('\OCP\Trashbin', 'preDelete', FilesHooks::class, 'onFileDelete'); |
103
|
|
|
Util::connectHook('OCP\Share', 'post_shared', FilesHooks::class, 'onFileShare'); |
104
|
|
|
Util::connectHook('OCP\Share', 'post_unshare', FilesHooks::class, 'onFileUnshare'); |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
|
108
|
|
|
public function registerCommentsHooks(IServerContainer $container) { |
109
|
|
|
// TODO: needed ? |
110
|
|
|
// OC::$server->getCommentsManager() |
111
|
|
|
// ->registerEventHandler( |
112
|
|
|
// function() { |
113
|
|
|
// return $this->getContainer() |
114
|
|
|
// ->query(FilesCommentsEvents::class); |
115
|
|
|
// } |
116
|
|
|
// ); |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
|