|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* class SolrConfigureJob|Firesphere\SolrSearch\Jobs\SolrConfigureJob Configure cores from the CMS |
|
4
|
|
|
* |
|
5
|
|
|
* @package Firesphere\Solr\Search |
|
6
|
|
|
* @author Simon `Firesphere` Erkelens; Marco `Sheepy` Hermo |
|
7
|
|
|
* @copyright Copyright (c) 2018 - now() Firesphere & Sheepy |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
namespace Firesphere\SolrSearch\Jobs; |
|
11
|
|
|
|
|
12
|
|
|
use Firesphere\SolrSearch\Tasks\SolrConfigureTask; |
|
13
|
|
|
use Psr\SimpleCache\InvalidArgumentException; |
|
14
|
|
|
use ReflectionException; |
|
15
|
|
|
use SilverStripe\Control\NullHTTPRequest; |
|
16
|
|
|
use SilverStripe\Core\Injector\Injector; |
|
17
|
|
|
use SilverStripe\ORM\ValidationException; |
|
18
|
|
|
use Symbiote\QueuedJobs\Services\AbstractQueuedJob; |
|
19
|
|
|
use Solarium\Exception\HttpException; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* Class SolrConfigureJob |
|
23
|
|
|
* |
|
24
|
|
|
* Generate, upload and activate a Solr Core through {@link SolrConfigureTask} |
|
25
|
|
|
* |
|
26
|
|
|
* @package Firesphere\Solr\Search |
|
27
|
|
|
*/ |
|
28
|
|
|
class SolrConfigureJob extends AbstractQueuedJob |
|
29
|
|
|
{ |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* My name |
|
33
|
|
|
* |
|
34
|
|
|
* @return string |
|
35
|
1 |
|
*/ |
|
36
|
|
|
public function getTitle(): string |
|
37
|
1 |
|
{ |
|
38
|
|
|
return _t(__CLASS__ . '.TITLE', 'Configure new or re-configure existing Solr cores'); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* Process the queue for indexes that need to be indexed properly |
|
43
|
|
|
* |
|
44
|
|
|
* @return void |
|
45
|
|
|
* @throws HTTPException |
|
46
|
|
|
* @throws ValidationException |
|
47
|
|
|
* @throws InvalidArgumentException |
|
48
|
|
|
*/ |
|
49
|
2 |
|
public function process() |
|
50
|
|
|
{ |
|
51
|
|
|
/** @var SolrConfigureTask $task */ |
|
52
|
2 |
|
$task = Injector::inst()->get(SolrConfigureTask::class); |
|
53
|
2 |
|
$task->run(new NullHTTPRequest()); |
|
54
|
|
|
// Mark as complete if everything is fine |
|
55
|
2 |
|
$this->isComplete = true; |
|
56
|
2 |
|
} |
|
57
|
|
|
} |
|
58
|
|
|
|