Code Duplication    Length = 61-66 lines in 2 locations

src/models/PartialFieldSubmission.php 1 location

@@ 15-80 (lines=66) @@
12
 * @property int $SubmittedFormID
13
 * @method PartialFormSubmission SubmittedForm()
14
 */
15
class PartialFieldSubmission extends SubmittedFormField
16
{
17
    /**
18
     * @var string
19
     */
20
    private static $table_name = 'PartialFieldSubmission';
21
22
    /**
23
     * @var array
24
     */
25
    private static $has_one = [
26
        'SubmittedForm' => PartialFormSubmission::class,
27
    ];
28
29
    /**
30
     * @param Member $member
31
     * @param array $context
32
     * @return boolean
33
     */
34
    public function canCreate($member = null, $context = [])
35
    {
36
        return false;
37
    }
38
39
    /**
40
     * @param Member $member
41
     *
42
     * @return boolean|string
43
     */
44
    public function canView($member = null)
45
    {
46
        if ($this->SubmittedFormID) {
47
            return $this->SubmittedForm()->canView($member);
48
        }
49
50
        return parent::canView($member);
51
    }
52
53
    /**
54
     * @param Member $member
55
     *
56
     * @return boolean|string
57
     */
58
    public function canEdit($member = null)
59
    {
60
        if ($this->SubmittedFormID) {
61
            return $this->SubmittedForm()->canEdit($member);
62
        }
63
64
        return parent::canEdit($member);
65
    }
66
67
    /**
68
     * @param Member $member
69
     *
70
     * @return boolean|string
71
     */
72
    public function canDelete($member = null)
73
    {
74
        if ($this->SubmittedFormID) {
75
            return $this->SubmittedForm()->canDelete($member);
76
        }
77
78
        return parent::canDelete($member);
79
    }
80
}
81

src/models/PartialFileFieldSubmission.php 1 location

@@ 14-74 (lines=61) @@
11
 * @property int $SubmittedFormID
12
 * @method PartialFormSubmission SubmittedForm()
13
 */
14
class PartialFileFieldSubmission extends SubmittedFileField
15
{
16
    private static $table_name = 'PartialFileFieldSubmission';
17
18
    private static $has_one = [
19
        'SubmittedForm' => PartialFormSubmission::class,
20
    ];
21
22
23
    /**
24
     * @param Member $member
25
     * @param array $context
26
     * @return boolean
27
     */
28
    public function canCreate($member = null, $context = [])
29
    {
30
        return false;
31
    }
32
33
    /**
34
     * @param Member $member
35
     *
36
     * @return bool
37
     */
38
    public function canView($member = null)
39
    {
40
        if ($this->SubmittedFormID) {
41
            return $this->SubmittedForm()->canView($member);
42
        }
43
44
        return parent::canView($member);
45
    }
46
47
    /**
48
     * @param Member $member
49
     *
50
     * @return bool
51
     */
52
    public function canEdit($member = null)
53
    {
54
        if ($this->SubmittedFormID) {
55
            return $this->SubmittedForm()->canEdit($member);
56
        }
57
58
        return parent::canEdit($member);
59
    }
60
61
    /**
62
     * @param Member $member
63
     *
64
     * @return bool
65
     */
66
    public function canDelete($member = null)
67
    {
68
        if ($this->SubmittedFormID) {
69
            return $this->SubmittedForm()->canDelete($member);
70
        }
71
72
        return parent::canDelete($member);
73
    }
74
}
75