Code Duplication    Length = 13-13 lines in 5 locations

code/model/EditableCustomRule.php 1 location

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

code/model/editableformfields/EditableOption.php 1 location

@@ 88-100 (lines=13) @@
85
     * @param array $args List of arguments passed to canCreate
86
     * @return DataObject Some parent dataobject to inherit permissions from
87
     */
88
    protected function getCanCreateContext($args) {
89
        // Inspect second parameter to canCreate for a 'Parent' context
90
        if(isset($args[1]['Parent'])) {
91
            return $args[1]['Parent'];
92
        }
93
        // Hack in currently edited page if context is missing
94
        if(Controller::has_curr() && Controller::curr() instanceof CMSMain) {
95
            return Controller::curr()->currentPage();
96
        }
97
98
        // No page being edited
99
        return null;
100
    }
101
102
    /**
103
     * @param Member $member

code/model/recipients/UserDefinedForm_EmailRecipientCondition.php 1 location

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

code/model/recipients/UserDefinedForm_EmailRecipient.php 1 location

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

code/model/editableformfields/EditableFormField.php 1 location

@@ 426-438 (lines=13) @@
423
     * @param array $args List of arguments passed to canCreate
424
     * @return SiteTree Parent page instance
425
     */
426
    protected function getCanCreateContext($args) {
427
        // Inspect second parameter to canCreate for a 'Parent' context
428
        if(isset($args[1]['Parent'])) {
429
            return $args[1]['Parent'];
430
        }
431
        // Hack in currently edited page if context is missing
432
        if(Controller::has_curr() && Controller::curr() instanceof CMSMain) {
433
            return Controller::curr()->currentPage();
434
        }
435
436
        // No page being edited
437
        return null;
438
    }
439
440
    /**
441
     * Check if can publish