StaffProfilesPage_Controller   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 8
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A init() 0 5 1
1
<?php
2
3
/**
4
 *@author nicolaas[at]sunnysideup.co.nz
5
 *@description: displays a list of staff profiles
6
 *
7
 */
8
class StaffProfilesPage extends Page
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...
9
{
10
    private static $icon = "mysite/images/treeicons/StaffProfilesPage";
0 ignored issues
show
Unused Code introduced by
The property $icon 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...
11
12
    private static $allowed_children = array("StaffProfilesOnePerson"); //can also be "none";
0 ignored issues
show
Unused Code introduced by
The property $allowed_children 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...
13
14
    private static $default_child = "StaffProfilesOnePerson";
0 ignored issues
show
Unused Code introduced by
The property $default_child 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...
15
16
    private static $db = array(
0 ignored issues
show
Unused Code introduced by
The property $db 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...
17
        "DefaultEmail" => "Varchar(255)",
18
        "SubjectLine" => "Varchar(255)"
19
    );
20
21
    private static $has_many = array(
0 ignored issues
show
Unused Code introduced by
The property $has_many 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...
22
        "StaffProfiles" => "StaffProfile"
23
    );
24
25
    public function getCMSFields()
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
        $fields = parent::getCMSFields();
28
        $fields->addFieldToTab("Root.Profiles", $defaultEmailTextField = new TextField("DefaultEmail"));
29
        $defaultEmailTextField->setRightTitle(
30
            _t(
31
                "StaffProfilesPage.DEFAULT_EMAIL_EXPLANATION",
32
                "This is the default email that will be used if a staff member does not have a unique email"
33
            )
34
        );
35
        $fields->addFieldToTab("Root.Profiles", $subjectLineTextField = new TextField("SubjectLine"));
36
        $subjectLineTextField->setRightTitle(
37
            _t(
38
                "StaffProfilesPage.SUBJECT_LINE_EXPLANATION",
39
                "Subject line for email, you can use [". implode("], [", array_keys(Config::inst()->get("StaffProfile", "subject_place_holders"))). "]" . " as placeholders"
40
            )
41
        );
42
        $fields->addFieldToTab(
43
            "Root.Profiles",
44
            new GridField(
45
                "StaffProfiles",
46
                "Staff Profiles",
47
                StaffProfile::get(),
48
                $config = GridFieldConfig_RelationEditor::create()
49
            )
50
        );
51
        if (class_exists("GridFieldSortableRows")) {
52
            $config->addComponent(new GridFieldSortableRows('Sort'));
53
        }
54
        return $fields;
55
    }
56
57
    public function StaffProfilesAll()
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...
58
    {
59
        return $this->StaffProfiles();
60
    }
61
}
62
63
class StaffProfilesPage_Controller extends Page_Controller
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
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...
64
{
65
    public function init()
66
    {
67
        parent::init();
68
        Requirements::themedCSS("StaffProfilesPage", "staffprofiles");
69
    }
70
}
71