Code Duplication    Length = 15-17 lines in 4 locations

lib/Events/FilesEvents.php 4 locations

@@ 153-167 (lines=15) @@
150
	 * @throws NotFoundException
151
	 * @throws QueryException
152
	 */
153
	public function onFileUpdate(array $params) {
154
		if (!$this->registerFullTextSearchServices()) {
155
			return;
156
		}
157
158
		$path = $this->get('path', $params, '');
159
		if ($path === '') {
160
			return;
161
		}
162
163
		$file = $this->filesService->getFileFromPath($this->userId, $path);
164
		$this->fullTextSearchManager->updateIndexStatus(
165
			'files', (string)$file->getId(), IIndex::INDEX_CONTENT
166
		);
167
	}
168
169
170
	/**
@@ 177-191 (lines=15) @@
174
	 * @throws InvalidPathException
175
	 * @throws QueryException
176
	 */
177
	public function onFileRename(array $params) {
178
		if (!$this->registerFullTextSearchServices()) {
179
			return;
180
		}
181
182
		$target = $this->get('newpath', $params, '');
183
		if ($target === '') {
184
			return;
185
		}
186
187
		$file = $this->filesService->getFileFromPath($this->userId, $target);
188
		$this->fullTextSearchManager->updateIndexStatus(
189
			'files', (string)$file->getId(), IIndex::INDEX_META
190
		);
191
	}
192
193
194
	/**
@@ 201-217 (lines=17) @@
198
	 * @throws NotFoundException
199
	 * @throws QueryException
200
	 */
201
	public function onFileTrash(array $params) {
202
		if (!$this->registerFullTextSearchServices()) {
203
			return;
204
		}
205
206
		// check if trashbin does not exist. -> onFileDelete
207
		// we do not index trashbin
208
		$path = $this->get('path', $params, '');
209
		if ($path === '') {
210
			return;
211
		}
212
213
		$file = $this->filesService->getFileFromPath($this->userId, $path);
214
		$this->fullTextSearchManager->updateIndexStatus(
215
			'files', (string)$file->getId(), IIndex::INDEX_REMOVE, true
216
		);
217
	}
218
219
220
	/**
@@ 227-241 (lines=15) @@
224
	 * @throws NotFoundException
225
	 * @throws QueryException
226
	 */
227
	public function onFileRestore(array $params) {
228
		if (!$this->registerFullTextSearchServices()) {
229
			return;
230
		}
231
232
		$path = $this->get('filePath', $params, '');
233
		if ($path === '') {
234
			return;
235
		}
236
237
		$file = $this->filesService->getFileFromPath($this->userId, $path);
238
		$this->fullTextSearchManager->updateIndexStatus(
239
			'files', (string)$file->getId(), IIndex::INDEX_FULL
240
		);
241
	}
242
243
244
	/**