TemplateoverviewPageExtension::TemplateList()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 6
nc 3
nop 0
1
<?php
2
3
/**
4
 *@author nicolaas[at]sunnysideup.co.nz
5
 *@description: adds functionality to controller for dev purposes only
6
 *
7
 **/
8
9
10
class TemplateoverviewPageExtension 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...
11
{
12
    protected $templateList = null;
13
14
15
    public function IncludeTemplateoverviewDevelopmentFooter()
16
    {
17
        if (Director::isDev()) {
18
            Requirements::javascript("templateoverview_advanced/javascript/TemplateoverviewExtension.js");
19
            Requirements::themedCSS("TemplateoverviewExtension", "templateoverview_advanced");
20
            return true;
21
        }
22
        return false;
23
    }
24
25
    public function NextTemplateoverviewPage()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
26
    {
27
        $list = $this->TemplateList();
28
        $doIt = false;
29
        if ($list) {
30
            foreach ($list as $page) {
31
                if ($doIt) {
32
                    return $page;
33
                }
34
                if ($page->ClassName == $this->owner->ClassName) {
35
                    $doIt = true;
36
                }
37
            }
38
        }
39
    }
40
41
    public function PrevTemplateoverviewPage()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
42
    {
43
        $list = $this->TemplateList();
44
        $doIt = false;
45
        if ($list) {
46
            foreach ($list as $page) {
47
                if ($page->ClassName == $this->owner->ClassName) {
48
                    $doIt = true;
49
                }
50
                if ($doIt && isset($previousPage)) {
51
                    return $previousPage;
52
                }
53
                $previousPage = $page;
54
            }
55
        }
56
    }
57
58
    public function TemplateList()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
59
    {
60
        if (!$this->templateList) {
61
            $api = Injector::inst()->get('TemplateoverviewPageAPI');
62
            if ($api) {
63
                $this->templateList = $api->ListOfAllClasses();
64
            }
65
        }
66
        return $this->templateList;
67
    }
68
69
    public function TemplateDescriptionForThisClass()
70
    {
71
        return TemplateoverviewDescription::get()
72
            ->filter(array("ClassNameLink" => $this->owner->ClassName))
73
            ->First();
74
    }
75
}
76