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

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