2022-09-07 04:05:40 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace SilverStripe\FrameworkTest\Extension;
|
|
|
|
|
2024-08-20 06:14:03 +02:00
|
|
|
use SilverStripe\Core\Extension;
|
2022-09-07 04:05:40 +02:00
|
|
|
use SilverStripe\Security\Permission;
|
|
|
|
use SilverStripe\Security\PermissionProvider;
|
|
|
|
|
2024-08-20 06:14:03 +02:00
|
|
|
class TestDataObjectExtension extends Extension implements PermissionProvider
|
2022-09-07 04:05:40 +02:00
|
|
|
{
|
|
|
|
public function providePermissions()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'TEST_DATAOBJECT_EDIT' => [
|
|
|
|
'name' => _t(
|
|
|
|
__CLASS__ . '.EditPermissionLabel',
|
|
|
|
'Manage a test object'
|
|
|
|
),
|
|
|
|
'category' => _t(
|
|
|
|
__CLASS__ . '.Category',
|
|
|
|
'Test Data Object'
|
|
|
|
),
|
|
|
|
],
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2024-08-27 05:39:21 +02:00
|
|
|
protected function canView($member = null)
|
2022-09-07 04:05:40 +02:00
|
|
|
{
|
|
|
|
return Permission::check('TEST_DATAOBJECT_EDIT', 'any', $member);
|
|
|
|
}
|
|
|
|
|
2024-08-27 05:39:21 +02:00
|
|
|
protected function canEdit($member = null)
|
2022-09-07 04:05:40 +02:00
|
|
|
{
|
|
|
|
return Permission::check('TEST_DATAOBJECT_EDIT', 'any', $member);
|
|
|
|
}
|
|
|
|
|
2024-08-27 05:39:21 +02:00
|
|
|
protected function canDelete($member = null)
|
2022-09-07 04:05:40 +02:00
|
|
|
{
|
|
|
|
return Permission::check('TEST_DATAOBJECT_EDIT', 'any', $member);
|
|
|
|
}
|
|
|
|
|
2024-08-27 05:39:21 +02:00
|
|
|
protected function canCreate($member = null, $context = [])
|
2022-09-07 04:05:40 +02:00
|
|
|
{
|
|
|
|
return Permission::check('TEST_DATAOBJECT_EDIT', 'any', $member);
|
|
|
|
}
|
|
|
|
}
|