Completed
Push — master ( 8de354...4e0f9f )
by Maxence
01:38
created

FilesHooks::onRemoteFileRename()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
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\Hooks;
32
33
34
use OCA\Files_FullTextSearch\AppInfo\Application;
35
use OCA\Files_FullTextSearch\Events\FilesEvents;
36
use OCP\AppFramework\QueryException;
37
use OCP\Files\InvalidPathException;
38
use OCP\Files\NotFoundException;
39
40
41
/**
42
 * Class FilesHooks
43
 *
44
 * @package OCA\Files_FullTextSearch\Hooks
45
 */
46
class FilesHooks {
47
48
49
	/**
50
	 * retrieve the FilesEvents' Controller
51
	 *
52
	 * @return FilesEvents
53
	 * @throws QueryException
54
	 */
55
	protected static function getController(): FilesEvents {
56
		$app = new Application();
57
58
		return $app->getContainer()
59
				   ->query(FilesEvents::class);
60
	}
61
62
63
	/**
64
	 * hook events: file is created
65
	 *
66
	 * @param array $params
67
	 *
68
	 * @throws InvalidPathException
69
	 * @throws NotFoundException
70
	 * @throws QueryException
71
	 */
72
	public static function onNewFile(array $params) {
73
		self::getController()
74
			->onNewFile($params);
75
	}
76
77
78
	/**
79
	 * hook events: file is updated
80
	 *
81
	 * @param array $params
82
	 *
83
	 * @throws QueryException
84
	 * @throws InvalidPathException
85
	 * @throws NotFoundException
86
	 */
87
	public static function onFileUpdate(array $params) {
88
		self::getController()
89
			->onFileUpdate($params);
90
	}
91
92
93
	/**
94
	 * hook events: file is renamed
95
	 *
96
	 * @param array $params
97
	 *
98
	 * @throws NotFoundException
99
	 * @throws QueryException
100
	 * @throws InvalidPathException
101
	 */
102
	public static function onFileRename(array $params) {
103
		self::getController()
104
			->onFileRename($params);
105
	}
106
107
108
	/**
109
	 * hook event: file is sent to trashbin
110
	 *
111
	 * @param array $params
112
	 *
113
	 * @throws InvalidPathException
114
	 * @throws NotFoundException
115
	 * @throws QueryException
116
	 */
117
	public static function onFileTrash(array $params) {
118
		self::getController()
119
			->onFileTrash($params);
120
	}
121
122
123
	/**
124
	 * hook event: file is deleted
125
	 *
126
	 * @param array $params
127
	 *
128
	 * @throws QueryException
129
	 */
130
	public static function onFileDelete(array $params) {
131
		self::getController()
132
			->onFileDelete($params);
133
	}
134
135
136
	/**
137
	 * hook event: file is restored
138
	 *
139
	 * @param array $params
140
	 *
141
	 * @throws InvalidPathException
142
	 * @throws NotFoundException
143
	 * @throws QueryException
144
	 */
145
	public static function onFileRestore(array $params) {
146
		self::getController()
147
			->onFileRestore($params);
148
	}
149
150
151
	/**
152
	 * hook event: file is shared
153
	 *
154
	 * @param array $params
155
	 *
156
	 * @throws QueryException
157
	 */
158
	public static function onFileShare(array $params) {
159
		self::getController()
160
			->onFileShare($params);
161
	}
162
163
164
	/**
165
	 * hook event: file is unshared
166
	 *
167
	 * @param array $params
168
	 *
169
	 * @throws QueryException
170
	 */
171
	public static function onFileUnshare(array $params) {
172
		self::getController()
173
			->onFileUnshare($params);
174
	}
175
176
177
	/**
178
	 * @param array $params
179
	 *
180
	 * @throws QueryException
181
	 */
182
	public static function onNewRemoteFile2(array $params) {
183
		self::getController()
184
			->onNewScannedFile2($params);
185
	}
186
187
188
	/**
189
	 * @param array $params
190
	 *
191
	 * @throws QueryException
192
	 */
193
	public static function onNewRemoteFile(array $params) {
194
		self::getController()
195
			->onNewScannedFile($params);
196
	}
197
198
199
	/**
200
	 * @param array $params
201
	 */
202
	public static function onRemoteFileUpdate(array $params) {
203
		\OC::$server->getLogger()
204
					->log(2, 'onRemoteFileUpdate ' . json_encode($params));
205
	}
206
207
	/**
208
	 * @param array $params
209
	 */
210
	public static function onRemoteFileRename(array $params) {
211
		\OC::$server->getLogger()
212
					->log(2, 'onRemoteFileRename ' . json_encode($params));
213
	}
214
215
216
	/**
217
	 * @param array $params
218
	 */
219
	public static function onRemoteFileDelete(array $params) {
220
		\OC::$server->getLogger()
221
					->log(2, 'onRemoteFileDelete ' . json_encode($params));
222
	}
223
224
225
}
226
227