Passed
Push — master ( 02b19f...79668c )
by Matthew
02:20
created

RecipeDirection::canEdit()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Dynamic\RecipeBook\Model;
4
5
use Dynamic\RecipeBook\Page\RecipePage;
6
use SilverStripe\Forms\FieldList;
7
use SilverStripe\Forms\HTMLEditor\HTMLEditorField;
8
use SilverStripe\ORM\DataObject;
9
10
/**
11
 * Class RecipeDirection
12
 * @package Dynamic\RecipeBook\Page
13
 *
14
 * @property string $Title
15
 * @property int $Sort
16
 * @property int $RecipeID
17
 * @method RecipePage Recipe()
18
 */
19
class RecipeDirection extends DataObject
20
{
21
    /**
22
     * @var array
23
     */
24
    private static $db = [
0 ignored issues
show
introduced by
The private property $db is not used, and could be removed.
Loading history...
25
        'Title' => 'HTMLText',
26
        'Sort' => 'Int',
27
    ];
28
29
    /**
30
     * @var array
31
     */
32
    private static $has_one = [
0 ignored issues
show
introduced by
The private property $has_one is not used, and could be removed.
Loading history...
33
        'Recipe' => RecipePage::class,
34
    ];
35
36
    /**
37
     * @var string
38
     */
39
    private static $default_sort = 'Sort';
0 ignored issues
show
introduced by
The private property $default_sort is not used, and could be removed.
Loading history...
40
41
    /**
42
     * @var string
43
     */
44
    private static $table_name = 'RecipeDirection';
0 ignored issues
show
introduced by
The private property $table_name is not used, and could be removed.
Loading history...
45
46
    /**
47
     * @return FieldList
48
     */
49
    public function getCMSFields()
50
    {
51
        $this->beforeUpdateCMSFields(function (FieldList $fields) {
52
            $fields->addFieldToTab(
53
                'Root.Main',
54
                HTMLEditorField::create('Title')
55
                    ->setTitle('Direction Step')
56
                    ->setRows(5)
57
            );
58
59
            $fields->removeByName('Sort');
60
        });
61
62
        return parent::getCMSFields();
63
    }
64
65
    /**
66
     * @param null $member
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $member is correct as it would always require null to be passed?
Loading history...
67
     * @param array $context
68
     * @return bool
69
     */
70
    public function canCreate($member = null, $context = [])
71
    {
72
        return true;
73
    }
74
75
    /**
76
     * @param null $member
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $member is correct as it would always require null to be passed?
Loading history...
77
     * @return bool
78
     */
79
    public function canEdit($member = null)
80
    {
81
        return true;
82
    }
83
84
    /**
85
     * @param null $member
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $member is correct as it would always require null to be passed?
Loading history...
86
     * @return bool
87
     */
88
    public function canDelete($member = null)
89
    {
90
        return true;
91
    }
92
93
    /**
94
     * @param null $member
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $member is correct as it would always require null to be passed?
Loading history...
95
     * @return bool
96
     */
97
    public function canView($member = null)
98
    {
99
        return true;
100
    }
101
}
102