src/Communibase/Connector.php
public function getByIds($entityType, array $ids, array $params = [])
    {
        $validIds = array_values(array_unique(array_filter($ids, [__CLASS__, 'isIdValid'])));

        if (count($validIds) === 0) {
            return [];
        }

        $doSortByIds = empty($params['sort']);
        $results = $this->search($entityType, ['_id' => ['$in' => $validIds]], $params);
        if (!$doSortByIds) {
            return $results;
        }

        $flipped = array_flip($validIds);
        foreach ($results as $result) {
            $flipped[$result['_id']] = $result;
        }
        return array_filter(array_values($flipped), function ($result) {
            return is_array($result) && count($result) > 0;
        });

    }
public function getByIds($entityType, array $ids, array $params = [])
    {
        $validIds = array_values(array_unique(array_filter($ids, [__CLASS__, 'isIdValid'])));

        if (count($validIds) === 0) {
            return [];
        }

        $doSortByIds = empty($params['sort']);
        $results = $this->search($entityType, ['_id' => ['$in' => $validIds]], $params);
        if (!$doSortByIds) {
            return $results;
        }

        $flipped = array_flip($validIds);
        foreach ($results as $result) {
            $flipped[$result['_id']] = $result;
        }
        return array_filter(array_values($flipped), function ($result) {
            return is_array($result) && count($result) > 0;
        });

    }
public function getByIds ( $ entityType , array $ ids , array $ params = [ ] ) { $ validIds = array_values ( array_unique ( array_filter ( $ ids , [ __CLASS__ , 'isIdValid' ] ) ) ) ; if ( count ( $ validIds ) === 0 ) { return [ ] ; } $ doSortByIds = empty ( $ params [ 'sort' ] ) ; $ results = $ this -> search ( $ entityType , [ '_id' => [ '$in' => $ validIds ] ] , $ params ) ; if ( ! $ doSortByIds ) { return $ results ; } $ flipped = array_flip ( $ validIds ) ; foreach ( $ results as $ result ) { $ flipped [ $ result [ '_id' ] ] = $ result ; } return array_filter ( array_values ( $ flipped ) , function ( $ result ) { return is_array ( $ result ) && count ( $ result ) > 0 ; } ) ; }
Get an array of entities by their ids

@param string $entityType
@param array $ids
@param array $params (optional)

@return array entities

@throws Exception
Get an array of entities by their ids