Last active
March 5, 2020 03:21
-
-
Save adrexia/4d47a4c1ebde244c19de413d66eaa201 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class MyDataObject extends DataObject implements PermissionProvider { | |
public function canView($member = NULL, $context = []) { | |
return Permission::check('MYOBJECT_VIEW'); | |
} | |
public function canEdit($member = NULL, $context = []) { | |
return Permission::check('MYOBJECT_EDIT'); | |
} | |
public function canDelete($member = NULL, $context = []) { | |
return Permission::check('MYOBJECT_DELETE'); | |
} | |
public function canCreate($member = NULL, $context = []) { | |
return Permission::check('MYOBJECT_CREATE'); | |
} | |
/** | |
* Get an array of {@link Permission} definitions that this object supports | |
* | |
* @return array | |
*/ | |
public function providePermissions() { | |
return array( | |
'MYOBJECT_VIEW' => array( | |
'name' => 'View My Object', | |
'category' => 'Module', | |
), | |
'MYOBJECT_EDIT' => array( | |
'name' => 'Edit My Object', | |
'category' => 'Module', | |
), | |
'MYOBJECT_DELETE' => array( | |
'name' => 'Delete My Object', | |
'category' => 'Module', | |
), | |
'MYOBJECT_CREATE' => array( | |
'name' => 'Create My Object', | |
'category' => 'Module' | |
) | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment