SolrConfigureJob::getTitle()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
ccs 1
cts 1
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
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