BuildAddonJob::getPackage()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
/**
3
 * A background job which builds a single add-on.
4
 */
5
class BuildAddonJob extends AbstractQueuedJob
6
{
7
    private $packageID;
8
9
    /**
10
     * @var array params
11
     * @throws Exception
12
     */
13
    public function __construct($params = array())
14
    {
15
        if (!empty($params['package'])) {
16
            $this->PackageID = $params['package'];
0 ignored issues
show
Bug introduced by
The property PackageID does not seem to exist. Did you mean packageID?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
17
        }
18
19
        $this->currentStep = 0;
20
        $this->totalSteps = 1;
21
    }
22
23
    protected function getPackage()
24
    {
25
        return Addon::get()->byID($this->PackageID);
0 ignored issues
show
Bug introduced by
The property PackageID does not seem to exist. Did you mean packageID?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
26
    }
27
28
    public function process()
29
    {
30
        $package = $this->getPackage();
31
        if (!$package->ID) {
32
            throw new Exception('Package not specified');
33
        }
34
35
        $builder = Injector::inst()->get('AddonBuilder');
36
37
        $builder->build($package);
38
39
        $package->BuildQueued = false;
40
        $package->write();
41
42
        // Send the package to stitch-data for data warehousing
43
        Injector::inst()->get('StitchDataSender')->sendAddon($package);
44
45
        $this->isComplete = true;
46
        $this->currentStep = 1;
47
    }
48
49
    /**
50
     * @return string
51
     */
52
    public function getTitle()
53
    {
54
        return 'Build Addon: ' . $this->getPackage()->Name;
55
    }
56
    /**
57
     * Return a signature for this queued job
58
     *
59
     * @return string
60
     */
61
    public function getSignature()
62
    {
63
        return md5(get_class($this) . $this->PackageID);
0 ignored issues
show
Bug introduced by
The property PackageID does not seem to exist. Did you mean packageID?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
64
    }
65
}
66