Sulu\Bundle\ContactBundle\Util\IndexComparatorInterface::compare PHP Method

compare() public method

Compares given ids a and b with their index in ids array.
public compare ( mixed $a, mixed $b, array $ids ) : integer
$a mixed
$b mixed
$ids array
return integer
    public function compare($a, $b, array $ids);

Usage Example

Example #1
0
 /**
  * {@inheritdoc}
  */
 public function findByIds($ids)
 {
     if (count($ids) === 0) {
         return [];
     }
     $parsed = $this->converter->convertIdsToGroupedIds($ids, ['a' => [], 'c' => []]);
     $accounts = $this->findAccountsByIds($parsed['a']);
     $contacts = $this->findContactsByIds($parsed['c']);
     $result = array_merge($accounts, $contacts);
     // the @ is necessary in case of a PHP bug https://bugs.php.net/bug.php?id=50688
     @usort($result, function ($a, $b) use($ids) {
         return $this->comparator->compare($a['id'], $b['id'], $ids);
     });
     return $result;
 }
All Usage Examples Of Sulu\Bundle\ContactBundle\Util\IndexComparatorInterface::compare
IndexComparatorInterface