Code Duplication    Length = 13-13 lines in 5 locations

code/model/EditableCustomRule.php 1 location

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

code/model/editableformfields/EditableFormField.php 1 location

@@ 444-456 (lines=13) @@
441
     * @param array $args List of arguments passed to canCreate
442
     * @return SiteTree Parent page instance
443
     */
444
    protected function getCanCreateContext($args)
445
    {
446
        // Inspect second parameter to canCreate for a 'Parent' context
447
        if (isset($args[1]['Parent'])) {
448
            return $args[1]['Parent'];
449
        }
450
        // Hack in currently edited page if context is missing
451
        if (Controller::has_curr() && Controller::curr() instanceof CMSMain) {
452
            return Controller::curr()->currentPage();
453
        }
454
455
        // No page being edited
456
        return null;
457
    }
458
459
    /**

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

@@ 304-316 (lines=13) @@
301
     * @param array $args List of arguments passed to canCreate
302
     * @return SiteTree Parent page instance
303
     */
304
    protected function getCanCreateContext($args)
305
    {
306
        // Inspect second parameter to canCreate for a 'Parent' context
307
        if (isset($args[1]['Form'])) {
308
            return $args[1]['Form'];
309
        }
310
        // Hack in currently edited page if context is missing
311
        if (Controller::has_curr() && Controller::curr() instanceof CMSMain) {
312
            return Controller::curr()->currentPage();
313
        }
314
315
        // No page being edited
316
        return null;
317
    }
318
319
    /**

code/model/recipients/UserDefinedForm_EmailRecipientCondition.php 1 location

@@ 84-96 (lines=13) @@
81
     * @param array $args List of arguments passed to canCreate
82
     * @return SiteTree Parent page instance
83
     */
84
    protected function getCanCreateContext($args)
85
    {
86
        // Inspect second parameter to canCreate for a 'Parent' context
87
        if (isset($args[1]['Parent'])) {
88
            return $args[1]['Parent'];
89
        }
90
        // Hack in currently edited page if context is missing
91
        if (Controller::has_curr() && Controller::curr() instanceof CMSMain) {
92
            return Controller::curr()->currentPage();
93
        }
94
95
        // No page being edited
96
        return null;
97
    }
98
99
    /**