mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
51 lines
1.1 KiB
PHP
51 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace SilverStripe\ORM\Tests\ChangeSetTest;
|
|
|
|
use SilverStripe\ORM\DataObject;
|
|
use SilverStripe\ORM\Versioning\Versioned;
|
|
use SilverStripe\Security\Permission;
|
|
|
|
/**
|
|
* Provides a set of targettable permissions for tested models
|
|
*
|
|
* @mixin Versioned
|
|
* @mixin DataObject
|
|
*/
|
|
trait Permissions
|
|
{
|
|
public function canEdit($member = null)
|
|
{
|
|
return $this->can(__FUNCTION__, $member);
|
|
}
|
|
|
|
public function canDelete($member = null)
|
|
{
|
|
return $this->can(__FUNCTION__, $member);
|
|
}
|
|
|
|
public function canCreate($member = null, $context = array())
|
|
{
|
|
return $this->can(__FUNCTION__, $member, $context);
|
|
}
|
|
|
|
public function canPublish($member = null, $context = array())
|
|
{
|
|
return $this->can(__FUNCTION__, $member, $context);
|
|
}
|
|
|
|
public function canUnpublish($member = null, $context = array())
|
|
{
|
|
return $this->can(__FUNCTION__, $member, $context);
|
|
}
|
|
|
|
public function can($perm, $member = null, $context = array())
|
|
{
|
|
$perms = [
|
|
"PERM_{$perm}",
|
|
'CAN_ALL',
|
|
];
|
|
return Permission::checkMember($member, $perms);
|
|
}
|
|
}
|