silverstripe /
silverstripe-elemental
| 1 | <?php |
||
| 2 | |||
| 3 | namespace DNADesign\Elemental\Tests\Src; |
||
| 4 | |||
| 5 | use DNADesign\Elemental\Models\ElementalArea; |
||
| 6 | use SilverStripe\Control\Controller; |
||
| 7 | use SilverStripe\Control\Director; |
||
| 8 | use SilverStripe\ORM\DataObject; |
||
| 9 | use SilverStripe\Dev\TestOnly; |
||
| 10 | use SilverStripe\Security\Permission; |
||
| 11 | use SilverStripe\Security\Security; |
||
| 12 | |||
| 13 | class TestDataObjectWithCMSEditLink extends DataObject implements TestOnly |
||
| 14 | { |
||
| 15 | private static $table_name = 'TestDataObjectWithCMSEditLink'; |
||
|
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
| 16 | |||
| 17 | private static array $db = [ |
||
|
0 ignored issues
–
show
|
|||
| 18 | 'Title' => 'Varchar(255)', |
||
| 19 | 'Content' => 'HTMLText', |
||
| 20 | ]; |
||
| 21 | |||
| 22 | private static $has_one = [ |
||
|
0 ignored issues
–
show
|
|||
| 23 | 'ElementalArea' => ElementalArea::class, |
||
| 24 | ]; |
||
| 25 | |||
| 26 | private static $owns = [ |
||
|
0 ignored issues
–
show
|
|||
| 27 | 'ElementalArea', |
||
| 28 | ]; |
||
| 29 | |||
| 30 | public function CMSEditLink() |
||
| 31 | { |
||
| 32 | $link = Controller::join_links( |
||
| 33 | 'admin/', |
||
| 34 | $this->ID, |
||
| 35 | ); |
||
| 36 | return Director::absoluteURL($link); |
||
| 37 | } |
||
| 38 | |||
| 39 | public function canDelete($member = null) |
||
| 40 | { |
||
| 41 | $member = $member ? $member : Security::getCurrentUser(); |
||
| 42 | $codes = ['CMS_ACCESS_CMSMain']; |
||
| 43 | return Permission::checkMember($member, $codes); |
||
| 44 | } |
||
| 45 | } |
||
| 46 |