silverstripe-frameworktest/code/TestDataObjectExtension.php

47 lines
1.2 KiB
PHP
Raw Permalink Normal View History

<?php
namespace SilverStripe\FrameworkTest\Extension;
2024-08-20 06:14:03 +02:00
use SilverStripe\Core\Extension;
use SilverStripe\Security\Permission;
use SilverStripe\Security\PermissionProvider;
2024-08-20 06:14:03 +02:00
class TestDataObjectExtension extends Extension implements PermissionProvider
{
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)
{
return Permission::check('TEST_DATAOBJECT_EDIT', 'any', $member);
}
2024-08-27 05:39:21 +02:00
protected function canEdit($member = null)
{
return Permission::check('TEST_DATAOBJECT_EDIT', 'any', $member);
}
2024-08-27 05:39:21 +02:00
protected function canDelete($member = null)
{
return Permission::check('TEST_DATAOBJECT_EDIT', 'any', $member);
}
2024-08-27 05:39:21 +02:00
protected function canCreate($member = null, $context = [])
{
return Permission::check('TEST_DATAOBJECT_EDIT', 'any', $member);
}
}