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

GenerateStaticCacheJob::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 GenerateStaticCacheJob
10
 * add pages to static cache based on list of URLs
11
 *
12
 * @package SilverStripe\StaticPublishQueue\Job
13
 */
14
class GenerateStaticCacheJob extends Job
15
{
16
    /**
17
     * @return string
18
     */
19
    public function getTitle()
20
    {
21
        return 'Generate a set of static pages from URLs';
22
    }
23
24
    /**
25
     * @param string $url
26
     * @param int $priority
27
     */
28
    protected function processUrl($url, $priority)
29
    {
30
        $meta = Publisher::singleton()->publishURL($url, true);
31
        $meta = (is_array($meta)) ? $meta : [];
32
        if (array_key_exists('success', $meta) && $meta['success']) {
33
            $this->markUrlAsProcessed($url);
34
35
            return;
36
        }
37
38
        $this->handleFailedUrl($url, $meta);
39
    }
40
}
41