public static function SwitchUserBlock::sortUserList in Devel 8
Same name and namespace in other branches
- 8.3 src/Plugin/Block/SwitchUserBlock.php \Drupal\devel\Plugin\Block\SwitchUserBlock::sortUserList()
- 8.2 src/Plugin/Block/SwitchUserBlock.php \Drupal\devel\Plugin\Block\SwitchUserBlock::sortUserList()
- 4.x src/Plugin/Block/SwitchUserBlock.php \Drupal\devel\Plugin\Block\SwitchUserBlock::sortUserList()
Helper callback for uasort() to sort accounts by last access.
File
- src/
Plugin/ Block/ SwitchUserBlock.php, line 270
Class
- SwitchUserBlock
- Provides a block for switching users.
Namespace
Drupal\devel\Plugin\BlockCode
public static function sortUserList(AccountInterface $a, AccountInterface $b) {
$a_access = (int) $a
->getLastAccessedTime();
$b_access = (int) $b
->getLastAccessedTime();
if ($a_access === $b_access) {
return 0;
}
// User never access to site.
if ($a_access === 0) {
return 1;
}
return $a_access > $b_access ? -1 : 1;
}