Code Duplication    Length = 14-14 lines in 5 locations

code/model/EditableCustomRule.php 1 location

@@ 122-135 (lines=14) @@
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($context)
123
    {
124
        // Inspect second parameter to canCreate for a 'Parent' context
125
        if (isset($context['Parent'])) {
126
            return $context['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
    /**
138
     * @param Member $member

code/model/editableformfields/EditableOption.php 1 location

@@ 122-135 (lines=14) @@
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($context)
123
    {
124
        // Inspect second parameter to canCreate for a 'Parent' context
125
        if(isset($context['Parent'])) {
126
            return $context['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
    /**
138
     * @param Member $member

code/model/recipients/UserDefinedForm_EmailRecipient.php 1 location

@@ 345-358 (lines=14) @@
342
     * @param array $args List of arguments passed to canCreate
343
     * @return SiteTree Parent page instance
344
     */
345
    protected function getCanCreateContext($context)
346
    {
347
        // Inspect second parameter to canCreate for a 'Parent' context
348
        if (isset($context['Form'])) {
349
            return $context['Form'];
350
        }
351
        // Hack in currently edited page if context is missing
352
        if (Controller::has_curr() && Controller::curr() instanceof CMSMain) {
353
            return Controller::curr()->currentPage();
354
        }
355
356
        // No page being edited
357
        return null;
358
    }
359
360
    /**
361
     * @param Member

code/model/recipients/UserDefinedForm_EmailRecipientCondition.php 1 location

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

code/model/editableformfields/EditableFormField.php 1 location

@@ 473-486 (lines=14) @@
470
     * @param array $args List of arguments passed to canCreate
471
     * @return SiteTree Parent page instance
472
     */
473
    protected function getCanCreateContext($context)
474
    {
475
        // Inspect second parameter to canCreate for a 'Parent' context
476
        if (isset($context['Parent'])) {
477
            return $context['Parent'];
478
        }
479
        // Hack in currently edited page if context is missing
480
        if (Controller::has_curr() && Controller::curr() instanceof CMSMain) {
481
            return Controller::curr()->currentPage();
482
        }
483
484
        // No page being edited
485
        return null;
486
    }
487
488
    /**
489
     * Check if can publish