Completed
Pull Request — master (#12)
by Matthew
13:05
created

SampleManageableDataObject::providePermissions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Dynamic\ManageableDataObject\Test\Model;
4
5
use Dynamic\ManageableDataObject\Extensions\ManageableObjectDataExtension;
6
use Dynamic\ManageableDataObject\Interfaces\ManageableDataObjectInterface;
7
use Dynamic\ViewableDataObject\Extensions\ViewableDataObject;
8
use SilverStripe\Dev\TestOnly;
9
use SilverStripe\Forms\FieldList;
10
use SilverStripe\Forms\RequiredFields;
11
use SilverStripe\ORM\DataObject;
12
use SilverStripe\Security\Permission;
13
use SilverStripe\Security\PermissionProvider;
14
15
/**
16
 * Class SampleManageableDataObject
17
 * @package Dynamic\ManageableDataObject\Test\Model
18
 *
19
 * @mixin ViewableDataObject
20
 * @mixin ManageableObjectDataExtension
21
 */
22
class SampleManageableDataObject extends DataObject implements PermissionProvider, ManageableDataObjectInterface, TestOnly
23
{
24
25
    /**
26
     * @var string
27
     */
28
    private static $listing_page_class = SampleManageableObjectPage::class;
0 ignored issues
show
introduced by
The private property $listing_page_class is not used, and could be removed.
Loading history...
29
30
    /**
31
     * @var array
32
     */
33
    private static $extensions = [
0 ignored issues
show
introduced by
The private property $extensions is not used, and could be removed.
Loading history...
34
        ViewableDataObject::class,
35
        ManageableObjectDataExtension::class,
36
    ];
37
38
    /**
39
     * @return array
40
     */
41
    public function providePermissions()
42
    {
43
        return [
44
            'MDO_Create',
45
            'MDO_Edit',
46
            'MDO_Delete',
47
            'MDO_View',
48
        ];
49
    }
50
51
	/**
52
	 * @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...
53
	 * @param array $context
54
	 *
55
	 * @return bool|int
56
	 */
57
    public function canCreate($member = null, $context = array())
58
    {
59
        return Permission::check('MDO_Create', 'any', $member);
60
    }
61
62
    /**
63
     * @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...
64
     *
65
     * @return bool|int
66
     */
67
    public function canEdit($member = null)
68
    {
69
        return Permission::check('MDO_Edit', 'any', $member);
70
    }
71
72
    /**
73
     * @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...
74
     *
75
     * @return bool|int
76
     */
77
    public function canDelete($member = null)
78
    {
79
        return Permission::check('MDO_Delete', 'any', $member);
80
    }
81
82
    /**
83
     * @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...
84
     *
85
     * @return bool|int
86
     */
87
    public function canView($member = null)
88
    {
89
        return Permission::check('MDO_View', 'any', $member);
90
    }
91
92
    /**
93
     * @param null $params
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $params is correct as it would always require null to be passed?
Loading history...
94
     *
95
     * @return FieldList
96
     */
97
    public function getFrontEndFields($params = null)
98
    {
99
        return parent::getFrontEndFields();
100
    }
101
102
    /**
103
     * @return FieldList
104
     */
105
    public function getFrontEndActions()
106
    {
107
        return FieldList::create();
108
    }
109
110
    /**
111
     * @return RequiredFields
112
     */
113
    public function getFrontEndRequiredFields()
114
    {
115
        return RequiredFields::create();
116
    }
117
}
118