GoogleDfpController::GoogleDfpSlotByAlias()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 3
nc 2
nop 1
1
<?php
2
3
/**
4
 * Google DFP Controller class.
5
 *
6
 *
7
 * @package SilverStripe-Google-DFP
8
 * @copyright 2017 Fractas Labs
9
 * @license https://opensource.org/licenses/BSD-3-Clause BSD-3-Clause
10
 * @link https://github.com/fractaslabs/silverstripe-google-dfp
11
 */
12
class GoogleDfpController extends Extension
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
13
{
14
    /**
15
     * Renders a banners HTML to template using $id as identifier
16
     *
17
     *
18
     * @param $id
19
     */
20
    public function GoogleDfpSlotByID($id = false)
21
    {
22
        $data = GoogleDfpSlotHelper::slot_by_id($id);
23
24
        return $data ? $data->renderWith('GoogleDfpSlot') : false;
25
    }
26
27
    /**
28
     * Renders a banners HTML to template using $alias as identifier
29
     *
30
     *
31
     * @param $alias
32
     */
33
    public function GoogleDfpSlotByAlias($alias = false)
34
    {
35
        $data = GoogleDfpSlotHelper::slot_by_alias($alias);
36
37
        return $data ? $data->renderWith('GoogleDfpSlot') : false;
38
    }
39
40
    /**
41
     * Fills a javascript with data array needed to initialize a banner show
42
     *
43
     */
44
    public function GoogleDfpSlotList()
45
    {
46
        return GoogleDfpSlotHelper::slot_list()->filter(array('Layout' => Controller::curr()->ClassName));
47
    }
48
49
    /**
50
     * Check method if is module enabled, used in GoogleDfpSlot.ss
51
     *
52
     * @return bool
53
     */
54
    public function GoogleDfpEnabled()
55
    {
56
        return GoogleDfpSlotHelper::enabled();
57
    }
58
59
    /**
60
     * Renders a javascript needed to initialize a banner show
61
     *
62
     */
63
    public function onAfterInit()
64
    {
65
        if (GoogleDfpSlotHelper::enabled() !== false) {
66
            Requirements::insertHeadTags($this->owner->renderWith('GoogleDfpHead'), 'GoogleDfpHead');
67
        }
68
    }
69
}
70