Completed
Pull Request — master (#289)
by Ingo
02:07
created

FileExtension::canView()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 2
eloc 3
nc 2
nop 1
1
<?php
2
3
namespace SilverStripe\AssetAdmin\Tests\Controller\AssetAdminTest;
4
5
use SilverStripe\Dev\TestOnly;
6
use SilverStripe\ORM\DataExtension;
7
8
class FileExtension extends DataExtension implements TestOnly
9
{
10
    public function canView($member = null)
0 ignored issues
show
Unused Code introduced by
The parameter $member is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
11
    {
12
        if ($this->owner->Name === 'disallowCanView.txt') {
13
            return false;
14
        }
15
    }
16
17
    public function canEdit($member = null)
18
    {
19
        if ($this->owner->Name === 'disallowCanEdit.txt') {
20
            return false;
21
        }
22
    }
23
24
    public function canDelete($member = null)
25
    {
26
        if ($this->owner->Name === 'disallowCanDelete.txt') {
27
            return false;
28
        }
29
    }
30
31
    public function canArchive($member = null)
32
    {
33
        if ($this->owner->Name === 'disallowCanDelete.txt') {
34
            return false;
35
        }
36
        return $this->owner->canDelete($member);
37
    }
38
39
40
    public function canCreate($member = null, $context = [])
41
    {
42
        if (isset($context['Parent']) && $context['Parent']->Name === 'disallowCanAddChildren') {
43
            return false;
44
        }
45
        if (isset($context['Upload']['name']) && $context['Upload']['name'] === 'disallowCanCreate.txt') {
46
            return false;
47
        }
48
    }
49
}
50