public static function EntityDisplayModeBase::sort

public static EntityDisplayModeBase::sort(ConfigEntityInterface $a, ConfigEntityInterface $b)

Helper callback for uasort() to sort configuration entities by weight and label.

Overrides ConfigEntityBase::sort

File

core/lib/Drupal/Core/Entity/EntityDisplayModeBase.php, line 59

Class

EntityDisplayModeBase
Base class for config entity types with settings for form and view modes.

Namespace

Drupal\Core\Entity

Code

public static function sort(ConfigEntityInterface $a, ConfigEntityInterface $b) {
  /** @var \Drupal\Core\Entity\EntityDisplayModeInterface $a */
  /** @var \Drupal\Core\Entity\EntityDisplayModeInterface $b */
  // Sort by the type of entity the view mode is used for.
  $a_type = $a->getTargetType();
  $b_type = $b->getTargetType();
  $type_order = strnatcasecmp($a_type, $b_type);
  return $type_order != 0 ? $type_order : parent::sort($a, $b);
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Entity!EntityDisplayModeBase.php/function/EntityDisplayModeBase::sort/8.1.x