Completed
Push — master ( ffb107...ae3279 )
by Maxence
04:05
created

ResetIndexes::resetIndexes()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 1
1
<?php
2
/**
3
 * FullTextSearch - Full text search framework for Nextcloud
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
namespace OCA\FullTextSearch\Migration;
28
29
use OCA\FullTextSearch\Db\IndexesRequest;
30
use OCA\FullTextSearch\Service\ProviderService;
31
use OCP\Migration\IOutput;
32
use OCP\Migration\IRepairStep;
33
34
/**
35
 * Class ResetDatabase
36
 *
37
 * @package OCA\FullTextSearch\Migration
38
 */
39
class ResetIndexes implements IRepairStep {
40
41
	/** @var IndexesRequest */
42
	protected $indexRequest;
43
44
	/** @var ProviderService */
45
	protected $providerService;
46
47
48
	/**
49
	 * ResetDatabase constructor.
50
	 *
51
	 * @param IndexesRequest $indexRequest
52
	 * @param ProviderService $providerService
53
	 */
54
	public function __construct(IndexesRequest $indexRequest, ProviderService $providerService) {
55
		$this->indexRequest = $indexRequest;
56
		$this->providerService = $providerService;
57
	}
58
59
60
	/**
61
	 * Returns the step's name
62
	 *
63
	 * @return string
64
	 * @since 9.1.0
65
	 */
66
	public function getName() {
67
		return 'Reset index';
68
	}
69
70
71
	/**
72
	 * @param IOutput $output
73
	 */
74
	public function run(IOutput $output) {
75
		$this->resetIndexes($output);
76
	}
77
78
79
	/**
80
	 * @param IOutput $output
81
	 */
82
	public function resetIndexes(IOutput $output) {
83
		$output->info('Reset database');
84
85
		$this->indexRequest->reset();
86
		$this->providerService->setProvidersAsNotIndexed();
87
88
89
		$output->finishProgress();
90
	}
91
92
}
93