Passed
Pull Request — master (#104)
by
unknown
02:44
created

DeleteStaticCacheJob::processUrl()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 6
nc 4
nop 2
dl 0
loc 11
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace SilverStripe\StaticPublishQueue\Job;
4
5
use SilverStripe\StaticPublishQueue\Job;
6
use SilverStripe\StaticPublishQueue\Publisher;
7
8
/**
9
 * Class DeleteStaticCacheJob
10
 * remove pages from static cache based on list of URLs
11
 *
12
 * @package SilverStripe\StaticPublishQueue\Job
13
 */
14
class DeleteStaticCacheJob extends Job
15
{
16
    /**
17
     * @var int
18
     * @config
19
     */
20
    private static $chunk_size = 2000;
0 ignored issues
show
introduced by
The private property $chunk_size is not used, and could be removed.
Loading history...
21
22
    /**
23
     * @return string
24
     */
25
    public function getTitle()
26
    {
27
        return 'Remove a set of static pages from the cache';
28
    }
29
30
    /**
31
     * @param string $url
32
     * @param int $priority
33
     */
34
    protected function processUrl($url, $priority)
35
    {
36
        $meta = Publisher::singleton()->purgeURL($url);
37
        $meta = (is_array($meta)) ? $meta : [];
38
        if (array_key_exists('success', $meta) && $meta['success']) {
39
            $this->markUrlAsProcessed($url);
40
41
            return;
42
        }
43
44
        $this->handleFailedUrl($url, $meta);
45
    }
46
}
47