Completed
Push — master ( 700351...497825 )
by Bram
01:37
created

WaitingListRegistration::singular_name()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
/**
3
 * WaitingListRegistration.php
4
 *
5
 * @author Bram de Leeuw
6
 * Date: 09/05/17
7
 */
8
9
namespace Broarm\EventTickets;
10
11
use DataObject;
12
use FieldList;
13
use ReadonlyField;
14
use Tab;
15
use TabSet;
16
17
/**
18
 * Class WaitingListRegistration
19
 *
20
 * @package Broarm\EventTickets
21
 *
22
 * @property string Title
23
 * @property string Email
24
 * @property string Telephone
25
 *
26
 * @method \CalendarEvent Event
27
 */
28
class WaitingListRegistration extends DataObject
29
{
30
    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...
31
        'Title' => 'Varchar(255)',
32
        'Email' => 'Varchar(255)',
33
        'Telephone' => 'Varchar(255)'
34
    );
35
36
    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...
37
        'Event' => 'CalendarEvent'
38
    );
39
40
    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...
41
        'Title' => 'Name',
42
        'Email' => 'Email',
43
        'Telephone' => 'Telephone'
44
    );
45
46
    public function getCMSFields()
47
    {
48
        $fields = new FieldList(new TabSet('Root', $mainTab = new Tab('Main')));
49
        $fields->addFieldsToTab('Root.Main', array(
50
            ReadonlyField::create('Title', _t('WaitingListRegistration.Name', 'Name')),
51
            ReadonlyField::create('Email', _t('WaitingListRegistration.Email', 'Email')),
52
            ReadonlyField::create('Telephone', _t('WaitingListRegistration.Telephone', 'Telephone'))
53
        ));
54
55
        $fields->addFieldsToTab('Root.Main', array());
56
        $this->extend('updateCMSFields', $fields);
57
        return $fields;
58
    }
59
60
    /**
61
     * Returns the singular name without the namespaces
62
     *
63
     * @return string
64
     */
65
    public function singular_name()
66
    {
67
        $name = explode('\\', parent::singular_name());
68
        return trim(end($name));
69
    }
70
71
    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...
72
    {
73
        return $this->Event()->canView($member);
0 ignored issues
show
Documentation Bug introduced by
The method Event does not exist on object<Broarm\EventTicke...aitingListRegistration>? 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...
74
    }
75
76
    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...
77
    {
78
        return $this->Event()->canEdit($member);
0 ignored issues
show
Documentation Bug introduced by
The method Event does not exist on object<Broarm\EventTicke...aitingListRegistration>? 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...
79
    }
80
81
    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...
82
    {
83
        return $this->Event()->canDelete($member);
0 ignored issues
show
Documentation Bug introduced by
The method Event does not exist on object<Broarm\EventTicke...aitingListRegistration>? 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...
84
    }
85
86
    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...
87
    {
88
        return $this->Event()->canCreate($member);
0 ignored issues
show
Documentation Bug introduced by
The method Event does not exist on object<Broarm\EventTicke...aitingListRegistration>? 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...
89
    }
90
}
91