UserFieldOption::getCMSFields()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.9
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
/**
3
 * AttendeeExtraFieldOption.php
4
 *
5
 * @author Bram de Leeuw
6
 * Date: 24/05/17
7
 */
8
9
namespace Broarm\EventTickets;
10
11
use CheckboxField;
12
use DataObject;
13
use FieldList;
14
use Tab;
15
use TabSet;
16
use TextField;
17
18
/**
19
 * Class AttendeeExtraFieldOption
20
 *
21
 * @property string Title
22
 * @property boolean Default
23
 * @method UserField Field
24
 */
25
class UserFieldOption extends DataObject
26
{
27
    private static $db = array(
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
28
        'Title' => 'Varchar(255)',
29
        'Default' => 'Boolean',
30
        'Sort' => 'Int'
31
    );
32
    
33
    private static $default_sort = 'Sort ASC';
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
34
35
    private static $has_one = array(
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
36
        'Field' => 'Broarm\EventTickets\UserField'
37
    );
38
39
    private static $summary_fields = array(
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
40
        'Title',
41
        'Default'
42
    );
43
44
    private static $translate = array(
45
        'Title'
46
    );
47
48
    public function getCMSFields()
49
    {
50
        $fields = new FieldList(new TabSet('Root', $mainTab = new Tab('Main')));
51
        $fields->addFieldsToTab('Root.Main', array(
52
            TextField::create('Title', _t('AttendeeExtraFieldOption.Title', 'Title')),
53
            CheckboxField::create('Default', _t('AttendeeExtraFieldOption.Default', 'Set as default'))
54
        ));
55
56
        $this->extend('updateCMSFields', $fields);
57
        return $fields;
58
    }
59
60
    public function canView($member = null)
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...
61
    {
62
        return $this->Field()->canView($member);
0 ignored issues
show
Documentation Bug introduced by
The method Field does not exist on object<Broarm\EventTickets\UserFieldOption>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
63
    }
64
65
    public function canEdit($member = null)
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...
66
    {
67
        return $this->Field()->canEdit($member);
0 ignored issues
show
Documentation Bug introduced by
The method Field does not exist on object<Broarm\EventTickets\UserFieldOption>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
68
    }
69
70
    public function canDelete($member = null)
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...
71
    {
72
        return $this->Field()->canDelete($member);
0 ignored issues
show
Documentation Bug introduced by
The method Field does not exist on object<Broarm\EventTickets\UserFieldOption>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
73
    }
74
75
    public function canCreate($member = null)
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...
76
    {
77
        return $this->Field()->canCreate($member);
0 ignored issues
show
Documentation Bug introduced by
The method Field does not exist on object<Broarm\EventTickets\UserFieldOption>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
78
    }
79
}
80