Code Duplication    Length = 14-14 lines in 3 locations

code/Model/EditableCustomRule.php 1 location

@@ 112-125 (lines=14) @@
109
     * @param array $args List of arguments passed to canCreate
110
     * @return DataObject Some parent dataobject to inherit permissions from
111
     */
112
    protected function getCanCreateContext($args)
113
    {
114
        // Inspect second parameter to canCreate for a 'Parent' context
115
        if (isset($args[1]['Parent'])) {
116
            return $args[1]['Parent'];
117
        }
118
        // Hack in currently edited page if context is missing
119
        if (Controller::has_curr() && Controller::curr() instanceof CMSMain) {
120
            return Controller::curr()->currentPage();
121
        }
122
123
        // No page being edited
124
        return null;
125
    }
126
127
    /**
128
     * @param Member $member

code/Model/Recipient/EmailRecipientCondition.php 1 location

@@ 130-143 (lines=14) @@
127
     * @param array $args List of arguments passed to canCreate
128
     * @return SiteTree Parent page instance
129
     */
130
    protected function getCanCreateContext($args)
131
    {
132
        // Inspect second parameter to canCreate for a 'Parent' context
133
        if (isset($args[1]['Parent'])) {
134
            return $args[1]['Parent'];
135
        }
136
        // Hack in currently edited page if context is missing
137
        if (Controller::has_curr() && Controller::curr() instanceof CMSMain) {
138
            return Controller::curr()->currentPage();
139
        }
140
141
        // No page being edited
142
        return null;
143
    }
144
145
    /**
146
     * @param Member

code/Model/EditableFormField.php 1 location

@@ 539-552 (lines=14) @@
536
     * @param array $args List of arguments passed to canCreate
537
     * @return SiteTree Parent page instance
538
     */
539
    protected function getCanCreateContext($args)
540
    {
541
        // Inspect second parameter to canCreate for a 'Parent' context
542
        if (isset($args[1]['Parent'])) {
543
            return $args[1]['Parent'];
544
        }
545
        // Hack in currently edited page if context is missing
546
        if (Controller::has_curr() && Controller::curr() instanceof CMSMain) {
547
            return Controller::curr()->currentPage();
548
        }
549
550
        // No page being edited
551
        return null;
552
    }
553
554
    /**
555
     * checks whether record is new, copied from SiteTree