Completed
Pull Request — master (#24)
by Jason
13:57
created

OperationManual::getCMSFields()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 8
Ratio 100 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 8
loc 8
c 0
b 0
f 0
ccs 2
cts 2
cp 1
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Dynamic\ProductCatalog\Docs;
4
5
use SilverStripe\Security\Permission;
6
use SilverStripe\Security\PermissionProvider;
7
8 View Code Duplication
class OperationManual extends ProductDoc implements PermissionProvider
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
9
{
10
    /**
11
     * @var string
12
     */
13
    private static $singular_name = 'Operation Manual';
14
15
    /**
16
     * @var string
17
     */
18 1
    private static $plural_name = 'OperationManuals';
19
20 1
    /**
21
     * @return FieldList
22 1
     */
23
    public function getCMSFields()
24 1
    {
25
        $fields = parent::getCMSFields();
26
27
        $fields->dataFieldByName('Download')->setFolderName('Uploads/Products/OperationManuals');
28
29
        return $fields;
30 1
    }
31
32
    /**
33 1
     * @return array
34 1
     */
35 1
    public function providePermissions()
36 1
    {
37
        return array(
38
            'Operation_EDIT' => 'Edit Operation Manuals',
39
            'Operation_DELETE' => 'Delete Operation Manuals',
40
            'Operation_CREATE' => 'Create Operation Manuals',
41
        );
42
    }
43
44 1
    /**
45
     * @param null $member
46 1
     *
47
     * @return bool|int
48
     */
49
    public function canCreate($member = null, $context = [])
50
    {
51
        return Permission::check('Operation_CREATE', 'any', $member);
52
    }
53
54 1
    /**
55
     * @param null $member
56 1
     *
57
     * @return bool|int
58
     */
59
    public function canEdit($member = null, $context = [])
0 ignored issues
show
Unused Code introduced by
The parameter $context 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...
60
    {
61
        return Permission::check('Operation_EDIT', 'any', $member);
62
    }
63
64 1
    /**
65
     * @param null $member
66 1
     *
67
     * @return bool|int
68
     */
69
    public function canDelete($member = null, $context = [])
0 ignored issues
show
Unused Code introduced by
The parameter $context 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...
70
    {
71
        return Permission::check('Operation_DELETE', 'any', $member);
72
    }
73
74 1
    /**
75
     * @param null $member
76 1
     *
77
     * @return bool
78
     */
79 1
    public function canView($member = null, $context = [])
0 ignored issues
show
Unused Code introduced by
The parameter $context 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...
80
    {
81
        return true;
82
    }
83
}
84