Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
13 / 13 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
CommitCommand | |
100.00% |
13 / 13 |
|
100.00% |
2 / 2 |
3 | |
100.00% |
1 / 1 |
configure | |
100.00% |
8 / 8 |
|
100.00% |
1 / 1 |
1 | |||
execute | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
2 |
1 | <?php |
2 | |
3 | /** |
4 | * Console command: commit to Solr |
5 | * |
6 | * PHP version 8 |
7 | * |
8 | * Copyright (C) Villanova University 2020. |
9 | * |
10 | * This program is free software; you can redistribute it and/or modify |
11 | * it under the terms of the GNU General Public License version 2, |
12 | * as published by the Free Software Foundation. |
13 | * |
14 | * This program is distributed in the hope that it will be useful, |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 | * GNU General Public License for more details. |
18 | * |
19 | * You should have received a copy of the GNU General Public License |
20 | * along with this program; if not, write to the Free Software |
21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
22 | * |
23 | * @category VuFind |
24 | * @package Console |
25 | * @author Demian Katz <demian.katz@villanova.edu> |
26 | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License |
27 | * @link https://vufind.org/wiki/development Wiki |
28 | */ |
29 | |
30 | namespace VuFindConsole\Command\Util; |
31 | |
32 | use Symfony\Component\Console\Attribute\AsCommand; |
33 | use Symfony\Component\Console\Input\InputArgument; |
34 | use Symfony\Component\Console\Input\InputInterface; |
35 | use Symfony\Component\Console\Output\OutputInterface; |
36 | |
37 | use function ini_get; |
38 | |
39 | /** |
40 | * Console command: commit to Solr |
41 | * |
42 | * @category VuFind |
43 | * @package Console |
44 | * @author Demian Katz <demian.katz@villanova.edu> |
45 | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License |
46 | * @link https://vufind.org/wiki/development Wiki |
47 | */ |
48 | #[AsCommand( |
49 | name: 'util/commit', |
50 | description: 'Solr commit tool' |
51 | )] |
52 | class CommitCommand extends AbstractSolrCommand |
53 | { |
54 | /** |
55 | * The name of the Solr command, for use in help messages. |
56 | * |
57 | * @var string |
58 | */ |
59 | protected $solrCommand = 'commit'; |
60 | |
61 | /** |
62 | * Configure the command. |
63 | * |
64 | * @return void |
65 | */ |
66 | protected function configure() |
67 | { |
68 | $this |
69 | ->setHelp('Sends a ' . $this->solrCommand . ' command to a Solr index.') |
70 | ->addArgument( |
71 | 'core', |
72 | InputArgument::OPTIONAL, |
73 | 'Name of Solr core to ' . $this->solrCommand, |
74 | 'Solr' |
75 | ); |
76 | } |
77 | |
78 | /** |
79 | * Run the command. |
80 | * |
81 | * @param InputInterface $input Input object |
82 | * @param OutputInterface $output Output object |
83 | * |
84 | * @return int 0 for success |
85 | * |
86 | * @SuppressWarnings(PHPMD.UnusedFormalParameter) |
87 | */ |
88 | protected function execute(InputInterface $input, OutputInterface $output) |
89 | { |
90 | // Check time limit; increase if necessary: |
91 | if (ini_get('max_execution_time') < 3600) { |
92 | ini_set('max_execution_time', '3600'); |
93 | } |
94 | |
95 | // Setup Solr Connection -- Allow core to be specified from command line. |
96 | $core = $input->getArgument('core'); |
97 | |
98 | // Commit to the Solr Index |
99 | $this->solr->commit($core); |
100 | return 0; |
101 | } |
102 | } |