Code Duplication    Length = 14-14 lines in 2 locations

code/models/ElementList.php 1 location

@@ 97-110 (lines=14) @@
94
        if (is_array($this->config()->get('allowed_elements'))) {
95
            $list = $this->config()->get('allowed_elements');
96
97
            if($this->config()->get('sort_types_alphabetically') !== false) {
98
                $sorted = array();
99
100
                foreach ($list as $class) {
101
                    $inst = singleton($class);
102
103
                    if ($inst->canCreate()) {
104
                        $sorted[$class] = singleton($class)->i18n_singular_name();
105
                    }
106
                }
107
108
                $list = $sorted;
109
                asort($list);
110
            }
111
        } else {
112
            $classes = ClassInfo::subclassesFor('BaseElement');
113
            $list = array();

code/extensions/ElementPageExtension.php 1 location

@@ 127-140 (lines=14) @@
124
        if (is_array($this->owner->config()->get('allowed_elements'))) {
125
            $list = $this->owner->config()->get('allowed_elements');
126
127
            if($this->owner->config()->get('sort_types_alphabetically') !== false) {
128
                $sorted = array();
129
130
                foreach ($list as $class) {
131
                    $inst = singleton($class);
132
133
                    if ($inst->canCreate()) {
134
                        $sorted[$class] = singleton($class)->i18n_singular_name();
135
                    }
136
                }
137
138
                $list = $sorted;
139
                asort($list);
140
            }
141
        } else {
142
            $classes = ClassInfo::subclassesFor('BaseElement');
143
            $list = array();