GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

PublishItemsTask::run()   A
last analyzed

Complexity

Conditions 4
Paths 3

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 9.7998
c 0
b 0
f 0
cc 4
nc 3
nop 1
1
<?php
2
3
namespace Symbiote\QueuedJobs\Tasks;
4
5
use Exception;
6
use SilverStripe\Dev\BuildTask;
7
use SilverStripe\ORM\DataObject;
8
use Symbiote\QueuedJobs\Jobs\PublishItemsJob;
9
10
/**
11
 * An example build task that publishes a bunch of pages - this demonstrates a realworld example of how the
12
 * queued jobs project can be used
13
 *
14
 * @author Marcus Nyeholt <[email protected]>
15
 * @license BSD http://silverstripe.org/bsd-license/
16
 */
17
class PublishItemsTask extends BuildTask
18
{
19
    /**
20
     * {@inheritDoc}
21
     * @var string
22
     */
23
    private static $segment = 'PublishItemsTask';
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
24
25
    /**
26
     * @throws Exception
27
     * @param HTTPRequest $request
28
     */
29
    public function run($request)
30
    {
31
        $root = $request->getVar('parent');
32
        if (!$root) {
33
            throw new Exception("Sorry, you must provide a parent node to publish from");
34
        }
35
36
        $item = DataObject::get_by_id('Page', $root);
37
38
        if ($item && $item->exists()) {
39
            $job = new PublishItemsJob($root);
40
            singleton('Symbiote\\QueuedJobs\\Services\\QueuedJobService')->queueJob($job);
41
        }
42
    }
43
}
44