diff --git a/core/lib/Drupal/Core/Entity/EntityManager.php b/core/lib/Drupal/Core/Entity/EntityManager.php index 46e7ae4..0b64c28 100644 --- a/core/lib/Drupal/Core/Entity/EntityManager.php +++ b/core/lib/Drupal/Core/Entity/EntityManager.php @@ -469,32 +469,29 @@ public function getAllBundleInfo() { */ public function getEntityTypeLabels($group = FALSE) { $options = array(); - $content_options = array(); $definitions = $this->getDefinitions(); - // Sort labels in alphabetical order. - ksort($definitions); - foreach ($definitions as $entity_type => $definition) { + foreach ($definitions as $entity_type_id => $definition) { if ($group) { - $group_label = $definition->getGroupLabel() ?: \Drupal::translation()->translate('Other', array(), array('context' => 'Entity type group')); - // Ensure that Content entities are floated to the top of lists. - if ($definition instanceof ContentEntityType) { - $content_options[$group_label][$entity_type] = $definition->getLabel(); - continue; - } - $options[$group_label][$entity_type] = $definition->getLabel(); + $options[$definition->getGroupLabel()][$entity_type_id] = $definition->getLabel(); } else { - $options[$entity_type] = $definition->getLabel(); + $options[$entity_type_id] = $definition->getLabel(); } } if ($group) { - // Sort the list alphabetically by group label. - array_multisort($options, SORT_DESC); + foreach ($options as &$group_options) { + // Sort the list alphabetically by group label. + array_multisort($group_options, SORT_ASC, SORT_NATURAL); + } + + // Make sure that the 'Content' group is situated at the top. + $content = \Drupal::translation()->translate('Content', array(), array('context' => 'Entity type group')); + $options = array($content => $options[$content]) + $options; } - return array_merge($content_options, $options); + return $options; } /** diff --git a/core/lib/Drupal/Core/Entity/EntityType.php b/core/lib/Drupal/Core/Entity/EntityType.php index b5f96a1..7c062d0 100644 --- a/core/lib/Drupal/Core/Entity/EntityType.php +++ b/core/lib/Drupal/Core/Entity/EntityType.php @@ -609,7 +609,7 @@ public function getGroup() { * {@inheritdoc} */ public function getGroupLabel() { - return isset($this->group_label) ? $this->group_label : $this->group; + return !empty($this->group_label) ? $this->group_label : \Drupal::translation()->translate('Other', array(), array('context' => 'Entity type group')); } }