VimeoDOD   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 8

Importance

Changes 0
Metric Value
wmc 9
lcom 1
cbo 8
dl 0
loc 52
c 0
b 0
f 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A updateCMSFields() 0 14 3
B HasVimeo() 0 17 5
A VimeosInThisSection() 0 8 1
1
<?php
2
3
class VimeoDOD extends DataExtension
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...
4
{
5
    private static $has_one = array(
0 ignored issues
show
Unused Code introduced by
The property $has_one is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
6
        "VimeoDataObject" => "VimeoDataObject"
7
    );
8
9
    private static $exclude_vimeo_from_page_classes = array();
0 ignored issues
show
Unused Code introduced by
The property $exclude_vimeo_from_page_classes is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
10
11
    private static $include_vimeo_in_page_classes = array();
0 ignored issues
show
Unused Code introduced by
The property $include_vimeo_in_page_classes is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
12
13
    public function updateCMSFields(FieldList $fields)
14
    {
15
        if ($this->HasVimeo()) {
16
            $listObject = VimeoDataObject::get();
17
            if ($listObject->count()) {
18
                $tab = _t("VimeoDOD.TAB", "Root.Vimeo");
19
                $list = array( 0 => _t("VimeoDOD.EMPTYSTRING", "--- select vimeo video ---")) + $listObject->map($index = 'ID', $titleField = 'Title')->toArray();
20
                $fields->addFieldToTab($tab, new DropdownField("VimeoDataObjectID", _t("VimeoDOD.URLFIELD", "Video"), $list));
21
                $linkToModelAdmin = _t("VimeoDOD.LINKTOMODELADMIN", "To edit your videos, please go to <a href=\"/admin/vimeos\">Vimeo Editing Page</a>.");
22
                $fields->addFieldToTab($tab, new LiteralField("VimeoDataObjectIDEDIT", "<p>$linkToModelAdmin</p>"));
23
            }
24
        }
25
        return $fields;
26
    }
27
28
    public function HasVimeo()
29
    {
30
        $hasVimeo = true;
31
        $includeClasses = $this->owner->Config()->get("include_vimeo_in_page_classes");
32
        if (count($includeClasses)) {
33
            if (!in_array($this->owner->ClassName, Config::inst()->get("VimeoDOD", "include_vimeo_in_page_classes"))) {
34
                $hasVimeo = false;
35
            }
36
        }
37
        $excludeClasses = Config::inst()->get("VimeoDOD", "exclude_vimeo_from_page_classes");
38
        if (count($excludeClasses)) {
39
            if (in_array($this->owner->ClassName, $excludeClasses)) {
40
                $hasVimeo = false;
41
            }
42
        }
43
        return $hasVimeo;
44
    }
45
46
    public function VimeosInThisSection()
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...
47
    {
48
        return Page::get()->filter(array(
49
            "ParentID" => array(intval($this->owner->ParentID), intval($this->owner->ID)),
50
            "VimeoDataObjectID:GreaterThan" => 0,
51
            "ShowInSearch" => 1
52
        ));
53
    }
54
}
55