Code Duplication    Length = 14-14 lines in 3 locations

code/Model/Recipient/EmailRecipientCondition.php 1 location

@@ 130-143 (lines=14) @@
127
     * @param array $args List of arguments passed to canCreate
128
     * @return SiteTree Parent page instance
129
     */
130
    protected function getCanCreateContext($args)
131
    {
132
        // Inspect second parameter to canCreate for a 'Parent' context
133
        if (isset($args[1]['Parent'])) {
134
            return $args[1]['Parent'];
135
        }
136
        // Hack in currently edited page if context is missing
137
        if (Controller::has_curr() && Controller::curr() instanceof CMSMain) {
138
            return Controller::curr()->currentPage();
139
        }
140
141
        // No page being edited
142
        return null;
143
    }
144
145
    /**
146
     * @param Member

code/Model/EditableCustomRule.php 1 location

@@ 111-124 (lines=14) @@
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
    {
113
        // Inspect second parameter to canCreate for a 'Parent' context
114
        if (isset($args[1]['Parent'])) {
115
            return $args[1]['Parent'];
116
        }
117
        // Hack in currently edited page if context is missing
118
        if (Controller::has_curr() && Controller::curr() instanceof CMSMain) {
119
            return Controller::curr()->currentPage();
120
        }
121
122
        // No page being edited
123
        return null;
124
    }
125
126
    /**
127
     * @param Member $member

code/Model/EditableFormField.php 1 location

@@ 538-551 (lines=14) @@
535
     * @param array $args List of arguments passed to canCreate
536
     * @return SiteTree Parent page instance
537
     */
538
    protected function getCanCreateContext($args)
539
    {
540
        // Inspect second parameter to canCreate for a 'Parent' context
541
        if (isset($args[1]['Parent'])) {
542
            return $args[1]['Parent'];
543
        }
544
        // Hack in currently edited page if context is missing
545
        if (Controller::has_curr() && Controller::curr() instanceof CMSMain) {
546
            return Controller::curr()->currentPage();
547
        }
548
549
        // No page being edited
550
        return null;
551
    }
552
553
    /**
554
     * checks whether record is new, copied from SiteTree