Code Duplication    Length = 13-13 lines in 5 locations

code/model/editableformfields/EditableOption.php 1 location

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

code/model/recipients/UserDefinedForm_EmailRecipient.php 1 location

@@ 323-335 (lines=13) @@
320
     * @param array $args List of arguments passed to canCreate
321
     * @return SiteTree Parent page instance
322
     */
323
    protected function getCanCreateContext($args)
324
    {
325
        // Inspect second parameter to canCreate for a 'Parent' context
326
        if (isset($args[1]['Form'])) {
327
            return $args[1]['Form'];
328
        }
329
        // Hack in currently edited page if context is missing
330
        if (Controller::has_curr() && Controller::curr() instanceof CMSMain) {
331
            return Controller::curr()->currentPage();
332
        }
333
334
        // No page being edited
335
        return null;
336
    }
337
338
    /**

code/model/EditableCustomRule.php 1 location

@@ 122-134 (lines=13) @@
119
     * @param array $args List of arguments passed to canCreate
120
     * @return DataObject Some parent dataobject to inherit permissions from
121
     */
122
    protected function getCanCreateContext($args)
123
    {
124
        // Inspect second parameter to canCreate for a 'Parent' context
125
        if (isset($args[1]['Parent'])) {
126
            return $args[1]['Parent'];
127
        }
128
        // Hack in currently edited page if context is missing
129
        if (Controller::has_curr() && Controller::curr() instanceof CMSMain) {
130
            return Controller::curr()->currentPage();
131
        }
132
133
        // No page being edited
134
        return null;
135
    }
136
137
    /**

code/model/recipients/UserDefinedForm_EmailRecipientCondition.php 1 location

@@ 121-133 (lines=13) @@
118
     * @param array $args List of arguments passed to canCreate
119
     * @return SiteTree Parent page instance
120
     */
121
    protected function getCanCreateContext($args)
122
    {
123
        // Inspect second parameter to canCreate for a 'Parent' context
124
        if (isset($args[1]['Parent'])) {
125
            return $args[1]['Parent'];
126
        }
127
        // Hack in currently edited page if context is missing
128
        if (Controller::has_curr() && Controller::curr() instanceof CMSMain) {
129
            return Controller::curr()->currentPage();
130
        }
131
132
        // No page being edited
133
        return null;
134
    }
135
136
    /**

code/model/editableformfields/EditableFormField.php 1 location

@@ 486-498 (lines=13) @@
483
     * @param array $args List of arguments passed to canCreate
484
     * @return SiteTree Parent page instance
485
     */
486
    protected function getCanCreateContext($args)
487
    {
488
        // Inspect second parameter to canCreate for a 'Parent' context
489
        if (isset($args[1]['Parent'])) {
490
            return $args[1]['Parent'];
491
        }
492
        // Hack in currently edited page if context is missing
493
        if (Controller::has_curr() && Controller::curr() instanceof CMSMain) {
494
            return Controller::curr()->currentPage();
495
        }
496
497
        // No page being edited
498
        return null;
499
    }
500
501
    /**