Completed
Push — master ( 679959...72d37e )
by Maxence
02:10
created

ExtensionService::dispatch()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
/**
3
 * Files_FullTextSearch - Index the content of your files
4
 *
5
 * This file is licensed under the Affero General Public License version 3 or
6
 * later. See the COPYING file.
7
 *
8
 * @author Maxence Lange <[email protected]>
9
 * @copyright 2018
10
 * @license GNU AGPL version 3 or any later version
11
 *
12
 * This program is free software: you can redistribute it and/or modify
13
 * it under the terms of the GNU Affero General Public License as
14
 * published by the Free Software Foundation, either version 3 of the
15
 * License, or (at your option) any later version.
16
 *
17
 * This program is distributed in the hope that it will be useful,
18
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
 * GNU Affero General Public License for more details.
21
 *
22
 * You should have received a copy of the GNU Affero General Public License
23
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
24
 *
25
 */
26
27
28
namespace OCA\Files_FullTextSearch\Service;
29
30
31
use OCA\Files_FullTextSearch\Model\FilesDocument;
32
use OCP\Files\Node;
33
use Symfony\Component\EventDispatcher\EventDispatcher;
34
use Symfony\Component\EventDispatcher\GenericEvent;
35
36
class ExtensionService {
37
38
	/** @var EventDispatcher */
39
	private $eventDispatcher;
40
41
	/** @var ConfigService */
42
	private $configService;
43
44
	/** @var MiscService */
45
	private $miscService;
46
47
48
	/**
49
	 * ExtensionService constructor.
50
	 *
51
	 * @param EventDispatcher $eventDispatcher
52
	 * @param ConfigService $configService
53
	 * @param MiscService $miscService
54
	 */
55
	public function __construct(
56
		EventDispatcher $eventDispatcher, ConfigService $configService, MiscService $miscService
57
	) {
58
		$this->eventDispatcher = $eventDispatcher;
59
		$this->configService = $configService;
60
		$this->miscService = $miscService;
61
	}
62
63
64
	public function fileIndexing(FilesDocument &$document, Node $file) {
65
		$this->dispatch(
66
			'\OCA\Files_FullTextSearch::onFileIndexing',
67
			['file' => $file, 'document' => &$document]
68
		);
69
	}
70
71
72
	/**
73
	 * @param string $context
74
	 * @param array $arguments
75
	 */
76
	private function dispatch($context, $arguments) {
77
		$this->eventDispatcher->dispatch($context, new GenericEvent(null, $arguments));
78
	}
79
80
}