You are here

private function DomainAccessField::sort in Domain Access 8

Sort the domain list, if possible.

File

domain_access/src/Plugin/views/field/DomainAccessField.php, line 41

Class

DomainAccessField
Field handler to present the link an entity on a domain.

Namespace

Drupal\domain_access\Plugin\views\field

Code

private function sort($a, $b) {
  $domainA = isset($a['rendered']['#options']['entity']) ? $a['rendered']['#options']['entity'] : 0;
  $domainB = isset($b['rendered']['#options']['entity']) ? $b['rendered']['#options']['entity'] : 0;
  if ($domainA !== 0) {
    return $domainA
      ->getWeight() > $domainB
      ->getWeight() ? 1 : 0;
  }

  // We don't have a domain object so sort as best we can.
  return strcmp($a['rendered']['#plain_text'], $b['rendered']['#plain_text']);
}