Code Duplication    Length = 14-14 lines in 2 locations

code/extensions/ElementPageExtension.php 1 location

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

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();