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

@@ 550-563 (lines=14) @@
547
     * @param array $args List of arguments passed to canCreate
548
     * @return SiteTree Parent page instance
549
     */
550
    protected function getCanCreateContext($args)
551
    {
552
        // Inspect second parameter to canCreate for a 'Parent' context
553
        if (isset($args[1]['Parent'])) {
554
            return $args[1]['Parent'];
555
        }
556
        // Hack in currently edited page if context is missing
557
        if (Controller::has_curr() && Controller::curr() instanceof CMSMain) {
558
            return Controller::curr()->currentPage();
559
        }
560
561
        // No page being edited
562
        return null;
563
    }
564
565
    /**
566
     * checks whether record is new, copied from SiteTree