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

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/editableformfields/EditableFormField.php 1 location

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