dynamic / silverstripe-manageable-dataobject
Allows frontend DataObject management
Installs: 2 892
Dependents: 1
Suggesters: 0
Security: 0
Stars: 2
Watchers: 7
Forks: 3
Open Issues: 1
Type:silverstripe-vendormodule
Requires
- dynamic/silverstripe-additional-formfields: ^2.0
- dynamic/viewable-dataobject: ^2.0
- silverstripe/recipe-cms: ^1.0@dev || ^4.0@dev
- silverstripe/vendor-plugin: ^1@dev
Requires (Dev)
This package is auto-updated.
Last update: 2024-10-27 03:21:21 UTC
README
Allow front-end management of DataObjects.
Requirements
- SilverStripe ^4.0
- Viewable Dataobject ^2.0
- Additional Form Fields ^2.0
Installation
composer require dynamic/silverstripe-manageable-dataobject
Configuration
MyPageController: managed_object: MyManageableObject extensions: - Dynamic\ManageableDataObject\Extensions\ManageableControllerExtension MyManageableObject: extensions: - Dynamic\ViewableDataObject\Extensions\ViewableDataObject - Dynamic\ManageableDataObject\Extensions\ManageableObjectExtension listing_page_class: MyPage
MyManageableObject
To utilize ManageableDataObject you must implement PermissionProvider
and methods defined in ManageableDataObjectInterface
. The example below is a very basic implementation of the PermissionProvider
and ManageableDataObjectInterface
methods.
<?php namespace Foo\Bar; use Dynamic\ManageableDataObject\Interfaces\ManageableDataObjectInterface; use SilverStripe\Forms\FieldList; use SilverStripe\Forms\RequiredFields; use SilverStripe\ORM\DataObject; use SilverStripe\Security\Permission; use SilverStripe\Security\PermissionProvider; class MyManageableObject extends DataObject implements PermissionProvider, ManageableDataObjectInterface { /** * @return array */ public function providePermissions() { return [ 'MDO_Create', 'MDO_Edit', 'MDO_Delete', 'MDO_View', ]; } /** * @param null $member * @param array $context * * @return bool|int */ public function canCreate($member = null, $context = array()) { return Permission::check('MDO_Create', 'any', $member); } /** * @param null $member * * @return bool|int */ public function canEdit($member = null) { return Permission::check('MDO_Edit', 'any', $member); } /** * @param null $member * * @return bool|int */ public function canDelete($member = null) { return Permission::check('MDO_Delete', 'any', $member); } /** * @param null $member * * @return bool|int */ public function canView($member = null) { return Permission::check('MDO_View', 'any', $member); } /** * @param null $params * * @return FieldList */ public function getFrontEndFields($params = null) { return parent::getFrontEndFields(); } /** * @return FieldList */ public function getFrontEndActions() { return FieldList::create(); } /** * @return RequiredFields */ public function getFrontEndRequiredFields() { return RequiredFields::create(); } }