Completed
Push — master ( 32bb9b...9e3fe8 )
by Jason
9s
created

BlocksVersionedObjectsTask::updateObjects()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 18
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 18
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 13
nc 3
nop 0
1
<?php
2
3
/**
4
 * Class BlocksVersionedObjectsTask
5
 */
6
class BlocksVersionedObjectsTask extends BuildTask
7
{
8
9
    /**
10
     * @var string
11
     */
12
    protected $title = 'Publish Block Objects';
13
14
    /**
15
     * @var string
16
     */
17
    protected $description = 'Migrate block objects from alpha releases';
18
19
    /**
20
     * @var bool
21
     */
22
    protected $enabled = true;
23
24
    /**
25
     * @param $request
26
     */
27
    public function run($request)
28
    {
29
        $this->updateObjects();
30
    }
31
32
    /**
33
     * migrate all promos based on page type.
34
     */
35
    public function updateObjects()
36
    {
37
        $objects = [
38
            'AccordionPanel',
39
            'PageSectionObject',
40
            'PhotoGalleryBlockImage',
41
            'PromoObject',
42
        ];
43
        $ct = 0;
44
        foreach ($objects as $object) {
45
            $results = $object::get();
46
            foreach ($results as $result) {
47
                $result->doPublish('Stage', 'Live');
48
                $ct++;
49
            }
50
        }
51
        echo '<p>'.$ct.' block objects updated.</p>';
52
    }
53
54
}