Conditions | 5 |
Paths | 7 |
Total Lines | 31 |
Code Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
34 | public function check() |
||
35 | { |
||
36 | $brokenCores = []; |
||
37 | |||
38 | /** |
||
39 | * @todo Revisit this when silverstripe/fulltextsearch has 4.x compat |
||
40 | */ |
||
41 | if (!class_exists('\\Solr')) { |
||
42 | return [ |
||
43 | EnvironmentCheck::ERROR, |
||
44 | 'Class `Solr` not found. Is the fulltextsearch module installed?' |
||
45 | ]; |
||
46 | } |
||
47 | |||
48 | $service = \Solr::service(); |
||
49 | foreach (\Solr::get_indexes($this->indexClass) as $index) { |
||
50 | $core = $index->getIndexName(); |
||
51 | if (!$service->coreIsActive($core)) { |
||
52 | $brokenCores[] = $core; |
||
53 | } |
||
54 | } |
||
55 | |||
56 | if (!empty($brokenCores)) { |
||
57 | return [ |
||
58 | EnvironmentCheck::ERROR, |
||
59 | 'The following indexes are unavailable: ' . implode($brokenCores, ', ') |
||
60 | ]; |
||
61 | } |
||
62 | |||
63 | return [EnvironmentCheck::OK, 'Expected indexes are available.']; |
||
64 | } |
||
65 | } |
||
66 |