Gather all ids, so we can retrieve all content in a single query

@param array $array
@param array $ids
@return array
16406
protected function gatherIdsFromTree(array $array, array $ids = array())
    {
        foreach ($array as $item) {
            $ids[] = $item['id'];
            if (isset($item['__children']) && count($item['__children'])) {
                $ids = $this->gatherIdsFromTree($item['__children'], $ids);
            }
        }

        return $ids;
    }
525744
private function groupIdsByFile(array $ids) : array
    {
        $covered = [];

        foreach ($ids as $id) {
            $file = mb_substr($id, 0, (int) mb_strpos($id, '::'));

            if (!isset($covered[$file])) {
                $covered[$file] = [];
            }

            $covered[$file][] = mb_substr($id, mb_strpos($id, '::') + 2);
        }

        return $covered;
    }
1171446
public function getWithFilter(int $id, array $keys): array
    {
        return $this->parent->performAPICallWithJsonResponse(
            'get',
            '/series/'.$id.'/filter',
            [
                'query' => ['keys' => join(',', $keys)]
            ]
        );
    }
1088152
private function getImages(array $ids)
    {
        if (empty($ids)) {
            return [];
        }

        $qb = $this->getImageRepository()->createQueryBuilder('o');

        $images = $qb
            ->where($qb->expr()->in('o.id', $ids))
            ->orderBy('o.position')
            ->getQuery()
            ->getResult();

        if (count($images) !== count($ids)) {
            throw $this->createNotFoundException('Unable to find one or more images.');
        }

        return $images;
    }
6131
public static function selectByIds($ids, array $options = [], array $criteria = [])
    {
        $criteria = static::cleanCriteria($criteria);
        if (empty($criteria)) {
            $criteria['select'] = ['*'];
        }

        if (is_array($ids)) {
            $ids = implode(',', $ids);
        }

        $pk = static::getPrimaryKeyStatic();
        if (!empty($ids)) {
            $idsPhrase = " $pk IN ($ids) ";

            $condition = array_get($criteria, 'condition');

            if (!empty($condition)) {
                $condition .= ' AND ' . $idsPhrase;
            } else {
                $condition = $idsPhrase;
            }

            $criteria['condition'] = $condition;
        }

        $data = static::selectByRequest($criteria, $options);

        $data = static::cleanResult($data, array_get($criteria, 'select'));
        if (!is_array($ids)) {
            $ids = explode(',', $ids);
        }
        if (count($data) != count($ids)) {
            $out = [];
            $continue = array_get_bool($options, ApiOptions::CONTINUES);
            foreach ($ids as $index => $id) {
                $found = false;
                foreach ($data as $record) {
                    if ($id == array_get($record, $pk)) {
                        $out[$index] = $record;
                        $found = true;
                        break;
                    }
                }
                if (!$found) {
                    $out[$index] = new NotFoundException("Record with identifier '$id' not found.");
                    if (!$continue) {
                        break;
                    }
                }
            }

            throw new BatchException($out, 'Batch Error: Not all requested records could be retrieved.');
        }

        return $data;
    }
343659
public function get(array $ids = [], array $codes = [], $offset = 0, $limit = self::MAX_GET_USERS): array
    {
        $options = ['json' => compact('ids', 'codes')];
        $options['json']['size'] = $limit;
        $options['json']['offset'] = $offset;

        /** @var JsonStream $stream */
        $stream = $this->client
            ->get(UserApi::generateUrl('users.json'), $options)
            ->getBody();

        return $stream->jsonSerialize()['users'];
    }
656568
public function getTags($id = false, array $array = [])
    {
        return $this->keyManager->getTags($id, $array, $this->section, $this->modelClass);
    }
411733
public function several(array $ids)
    {
        $results = [];

        foreach ($ids as $cacheId) {
            if ($this->cache->test($cacheId)) {
                $results[$cacheId] = $this->cache->load($cacheId);
            }

        }

        return $results;
    }
339670
public function several(array $ids)
    {
        $result = [];
        foreach ($ids as $id) {
            if ($this->has($id)) {
                $result[$id] = $this->get($id);
            }
        }
        return $result;

    }
595837
public function many( array $ids = [] ) {
        if( count( $ids ) === 0 ) {
            return [];
        }

        $pages = array_chunk( $ids, $this->maxPageSize() );

        $requests = [];
        foreach( $pages as $page ) {
            $requests[] = [ 'ids' => implode( ',', $page ) ];
        }

        $responses = $this->requestMany( $requests );

        $result = [];
        foreach( $responses as $response ) {
            $result = array_merge( $result, $response->json() );
        }

        return $result;
    }
841468
public function findByIds($ids)
    {
        if (!is_array($ids)) {
            $ids = explode(',', $ids);
        }

        return $this->createQueryBuilder('ml')
            ->andWhere('ml.id IN (:ids)')
            ->setParameter('ids', $ids)
            ->getQuery()
            ->getResult();
    }
1025799
public function getByIds($ids, $prepareResults = true)
    {
        $queryBuilder = $this->getSelectQueryBuilder();
        $connection   = $queryBuilder->getConnection();
        $rows         = $queryBuilder->where(
            $queryBuilder->expr()->in($this->getUniqueId(), array_map(function ($id) use ($connection) {
                return $connection->quote($id);
            }, $ids))
        )->execute()->fetchAll();

        if ($prepareResults) {
            $this->prepareResults($rows);
        }

        return $rows;
    }
1012926
public function getContentByIds(array $identifiers)
    {
        $items = array();

        foreach ($identifiers as $id) {

            $items[$id] = $this->getContentById($id);
        }

        return $items;
    }
377831
public function deleteByIdArray(array $ids)
    {
        $data['ids'] = $ids;

        $deleteResult = $this->getRequest()->request(
            'DELETE',
            $this->getRequestUrl('inputs'),
            $data
        );

        return $deleteResult['status'];
    }
301640
public function getReadRequest($ids)
    {
        $db = $this->_getConnection();
        $table = $this->table;
        $self = $this;
        $primary = $this->_getPrimaryKetArray();

        $request = new StorageDataRequest(
            [$ids],
            function ($ids) use ($db, $table, $self, $primary) {
                if (!$db) {
                    $self->logError('Missing connection on getReadRequest on table: ' . $table);
                    return false;
                }

                $whereLines = [];
                foreach ($ids as $id) {
                    $whereArray = [];
                    $whereBind = $self->prepareBind($self->prepareKey($primary, $id), $db);
                    foreach ($whereBind as $key => $value) {
                        $whereArray[] = $key . ' = ' . $value;
                    }
                    $whereLines[] = implode(' AND ', $whereArray);
                }


                $query = 'SELECT * FROM ' . $table
                    . ' WHERE (' . implode(' ) OR (', $whereLines) . ')';


                $stmnt = $db->query($query);

                if (!$stmnt) {
                    $this->logError('Cannot execute getReadRequest on table: ' . $table . ':' . implode(',', $db->errorInfo()), [
                        'code' => $db->errorCode(),
                    ]);

                    return false;
                }

                $result = $stmnt->fetchAll(PDO::FETCH_ASSOC);

                if (!$result && (int) $stmnt->errorCode() > 0) {
                    $this->logError('Error on execution on getReadRequest on table: ' . $table . ':' . implode(',',
                            $stmnt->errorInfo()), [
                        'code' => $stmnt->errorCode(),
                    ]);

                    return false;
                }

                return $result;
            });

        return $request;
    }
192783
public function findByIds(array $ids): array
    {
        $spec = $this->createSpecification()->where(['id' => $ids]);

        return $this->findAll($spec);
    }
1169443
public function idsToMongo(array $ids)
    {
        foreach ($ids as &$id) {
            $id = $this->idToMongo($id);
        }

        return $ids;
    }