| 1 | <?php |
||
| 2 | |||
| 3 | namespace Dynamic\ManageableDataObject\Test\Model; |
||
| 4 | |||
| 5 | use Dynamic\ManageableDataObject\Extensions\ManageableObjectExtension; |
||
| 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 ManageableObjectExtension |
||
| 21 | */ |
||
| 22 | class SampleManageableDataObject extends DataObject implements PermissionProvider, ManageableDataObjectInterface, TestOnly |
||
| 23 | { |
||
| 24 | |||
| 25 | /** |
||
| 26 | * @var string |
||
| 27 | */ |
||
| 28 | private static $table_name = 'SampleManageableDataObject'; |
||
|
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
| 29 | |||
| 30 | /** |
||
| 31 | * @var string |
||
| 32 | */ |
||
| 33 | private static $listing_page_class = SampleManageableObjectPage::class; |
||
|
0 ignored issues
–
show
|
|||
| 34 | |||
| 35 | /** |
||
| 36 | * @var array |
||
| 37 | */ |
||
| 38 | private static $extensions = [ |
||
|
0 ignored issues
–
show
|
|||
| 39 | ViewableDataObject::class, |
||
| 40 | ManageableObjectExtension::class, |
||
| 41 | ]; |
||
| 42 | |||
| 43 | /** |
||
| 44 | * @return array |
||
| 45 | */ |
||
| 46 | public function providePermissions() |
||
| 47 | { |
||
| 48 | return [ |
||
| 49 | 'MDO_Create', |
||
| 50 | 'MDO_Edit', |
||
| 51 | 'MDO_Delete', |
||
| 52 | 'MDO_View', |
||
| 53 | ]; |
||
| 54 | } |
||
| 55 | |||
| 56 | /** |
||
| 57 | * @param null $member |
||
|
0 ignored issues
–
show
|
|||
| 58 | * @param array $context |
||
| 59 | * |
||
| 60 | * @return bool|int |
||
| 61 | */ |
||
| 62 | public function canCreate($member = null, $context = array()) |
||
| 63 | { |
||
| 64 | return Permission::check('MDO_Create', 'any', $member); |
||
| 65 | } |
||
| 66 | |||
| 67 | /** |
||
| 68 | * @param null $member |
||
|
0 ignored issues
–
show
|
|||
| 69 | * |
||
| 70 | * @return bool|int |
||
| 71 | */ |
||
| 72 | public function canEdit($member = null) |
||
| 73 | { |
||
| 74 | return Permission::check('MDO_Edit', 'any', $member); |
||
| 75 | } |
||
| 76 | |||
| 77 | /** |
||
| 78 | * @param null $member |
||
|
0 ignored issues
–
show
|
|||
| 79 | * |
||
| 80 | * @return bool|int |
||
| 81 | */ |
||
| 82 | public function canDelete($member = null) |
||
| 83 | { |
||
| 84 | return Permission::check('MDO_Delete', 'any', $member); |
||
| 85 | } |
||
| 86 | |||
| 87 | /** |
||
| 88 | * @param null $member |
||
|
0 ignored issues
–
show
|
|||
| 89 | * |
||
| 90 | * @return bool|int |
||
| 91 | */ |
||
| 92 | public function canView($member = null) |
||
| 93 | { |
||
| 94 | return Permission::check('MDO_View', 'any', $member); |
||
| 95 | } |
||
| 96 | |||
| 97 | /** |
||
| 98 | * @param null $params |
||
|
0 ignored issues
–
show
|
|||
| 99 | * |
||
| 100 | * @return FieldList |
||
| 101 | */ |
||
| 102 | public function getFrontEndFields($params = null) |
||
| 103 | { |
||
| 104 | return parent::getFrontEndFields(); |
||
| 105 | } |
||
| 106 | |||
| 107 | /** |
||
| 108 | * @return FieldList |
||
| 109 | */ |
||
| 110 | public function getFrontEndActions() |
||
| 111 | { |
||
| 112 | return FieldList::create(); |
||
| 113 | } |
||
| 114 | |||
| 115 | /** |
||
| 116 | * @return RequiredFields |
||
| 117 | */ |
||
| 118 | public function getFrontEndRequiredFields() |
||
| 119 | { |
||
| 120 | return RequiredFields::create(); |
||
| 121 | } |
||
| 122 | } |
||
| 123 |