Code Duplication    Length = 14-14 lines in 2 locations

code/models/ElementList.php 1 location

@@ 104-117 (lines=14) @@
101
        if (is_array($this->config()->get('allowed_elements'))) {
102
            $list = $this->config()->get('allowed_elements');
103
104
            if($this->config()->get('sort_types_alphabetically') !== false) {
105
                $sorted = array();
106
107
                foreach ($list as $class) {
108
                    $inst = singleton($class);
109
110
                    if ($inst->canCreate()) {
111
                        $sorted[$class] = singleton($class)->i18n_singular_name();
112
                    }
113
                }
114
115
                $list = $sorted;
116
                asort($list);
117
            }
118
        } else {
119
            $classes = ClassInfo::subclassesFor('BaseElement');
120
            $list = array();

code/extensions/ElementPageExtension.php 1 location

@@ 135-148 (lines=14) @@
132
        if (is_array($this->owner->config()->get('allowed_elements'))) {
133
            $list = $this->owner->config()->get('allowed_elements');
134
135
            if($this->owner->config()->get('sort_types_alphabetically') !== false) {
136
                $sorted = array();
137
138
                foreach ($list as $class) {
139
                    $inst = singleton($class);
140
141
                    if ($inst->canCreate()) {
142
                        $sorted[$class] = singleton($class)->i18n_singular_name();
143
                    }
144
                }
145
146
                $list = $sorted;
147
                asort($list);
148
            }
149
        } else {
150
            $classes = ClassInfo::subclassesFor('BaseElement');
151
            $list = array();