You are here

private function DomainSource::sort in Domain Access 8

Sort the domain list, if possible.

File

domain_source/src/Plugin/views/field/DomainSource.php, line 40

Class

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

Namespace

Drupal\domain_source\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']);
}