Code Duplication    Length = 13-13 lines in 5 locations

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
    /**

code/model/editableformfields/EditableOption.php 1 location

@@ 121-133 (lines=13) @@
118
     * @param array $args List of arguments passed to canCreate
119
     * @return DataObject Some parent dataobject to inherit permissions from
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/recipients/UserDefinedForm_EmailRecipient.php 1 location

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