PHP code example of dynamic / silverstripe-manageable-dataobject
1. Go to this page and download the library: Download dynamic/silverstripe-manageable-dataobject library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
dynamic / silverstripe-manageable-dataobject example snippets
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();
}
}