Passed
Push — 4 ( cadd86...a847d9 )
by Guy
11:20 queued 11s
created

TestDataObjectWithCMSEditLink::CMSEditLink()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 7
rs 10
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
The private property $table_name is not used, and could be removed.
Loading history...
16
17
    private static array $db = [
0 ignored issues
show
introduced by
The private property $db is not used, and could be removed.
Loading history...
18
        'Title' => 'Varchar(255)',
19
        'Content' => 'HTMLText',
20
    ];
21
22
    private static $has_one = [
0 ignored issues
show
introduced by
The private property $has_one is not used, and could be removed.
Loading history...
23
        'ElementalArea' => ElementalArea::class,
24
    ];
25
26
    private static $owns = [
0 ignored issues
show
introduced by
The private property $owns is not used, and could be removed.
Loading history...
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