Code Duplication    Length = 14-14 lines in 2 locations

code/extensions/ElementPageExtension.php 1 location

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

code/models/ElementList.php 1 location

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