ClearDirtyClassesJob::process()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 7
ccs 5
cts 5
cp 1
crap 1
rs 10
c 1
b 0
f 0
1
<?php
2
/**
3
 * class ClearDirtyClassesJob|Firesphere\SolrSearch\Jobs\ClearDirtyClassesJob Clear out the dirty classes by pushing
4
 * them again to solr
5
 *
6
 * @package Firesphere\Solr\Search
7
 * @author Simon `Firesphere` Erkelens; Marco `Sheepy` Hermo
8
 * @copyright Copyright (c) 2018 - now() Firesphere & Sheepy
9
 */
10
11
namespace Firesphere\SolrSearch\Jobs;
12
13
use Firesphere\SolrSearch\Tasks\ClearDirtyClassesTask;
14
use ReflectionException;
15
use SilverStripe\Control\NullHTTPRequest;
16
use SilverStripe\ORM\ValidationException;
17
use Solarium\Exception\HttpException;
18
use Symbiote\QueuedJobs\Services\AbstractQueuedJob;
19
20
/**
21
 * Class ClearDirtyClassesJob is the queued job version of the ClearDirtyClassesTask
22
 *
23
 * Clean up any dirty classes in Solr due to objects not being updated properly
24
 *
25
 * @package Firesphere\Solr\Search
26
 */
27
class ClearDirtyClassesJob extends AbstractQueuedJob
28
{
29
30
    /**
31
     * Give this puppy a name
32
     *
33
     * @return string Title of this job
34
     */
35 1
    public function getTitle()
36
    {
37 1
        return _t(self::class . '.CLEARSOLRDIRTY', 'Clear out dirty objects in Solr');
38
    }
39
40
    /**
41
     * Run the dirty class cleanup task from Queued Jobs
42
     *
43
     * @throws HTTPException
44
     * @throws ValidationException
45
     * @throws ReflectionException
46
     */
47 1
    public function process()
48
    {
49 1
        $request = new NullHTTPRequest();
50 1
        $task = new ClearDirtyClassesTask();
51 1
        $task->run($request);
52
53 1
        $this->isComplete = true;
54 1
    }
55
}
56