public function getDocuments(array $idList, $callable = null)
    {
        $idListToFindDirectly = $idList;

        // try to egt document from pool if enabled
        $documentsInDocumentPool = array();
        if ($this->isDocumentPoolEnabled() && !$callable) {
            $documentsInDocumentPool = $this->getDocumentsFromDocumentPool($idList);
            if (count($documentsInDocumentPool) === count($idList)) {
                return $documentsInDocumentPool;
            }

            // skip ids already found in pool
            $idListToFindDirectly = array_diff_key(
                array_map('strval', $idList),
                array_keys($documentsInDocumentPool)
            );
        }

        // get documents directly
        $cursor = $this->find();

        if (is_callable($callable)) {
            call_user_func($callable, $cursor);
        }

        $documentsGettingDirectly = $cursor->byIdList($idListToFindDirectly)->findAll();
        if (empty($documentsGettingDirectly)) {
            return $documentsInDocumentPool ? $documentsInDocumentPool : array();
        }

        if ($this->isDocumentPoolEnabled()) {
            $this->addDocumentsToDocumentPool($documentsGettingDirectly);
        }

        return $documentsGettingDirectly + $documentsInDocumentPool;
    }
public function getDocuments(array $idList, $callable = null)
    {
        $idListToFindDirectly = $idList;

        // try to egt document from pool if enabled
        $documentsInDocumentPool = array();
        if ($this->isDocumentPoolEnabled() && !$callable) {
            $documentsInDocumentPool = $this->getDocumentsFromDocumentPool($idList);
            if (count($documentsInDocumentPool) === count($idList)) {
                return $documentsInDocumentPool;
            }

            // skip ids already found in pool
            $idListToFindDirectly = array_diff_key(
                array_map('strval', $idList),
                array_keys($documentsInDocumentPool)
            );
        }

        // get documents directly
        $cursor = $this->find();

        if (is_callable($callable)) {
            call_user_func($callable, $cursor);
        }

        $documentsGettingDirectly = $cursor->byIdList($idListToFindDirectly)->findAll();
        if (empty($documentsGettingDirectly)) {
            return $documentsInDocumentPool ? $documentsInDocumentPool : array();
        }

        if ($this->isDocumentPoolEnabled()) {
            $this->addDocumentsToDocumentPool($documentsGettingDirectly);
        }

        return $documentsGettingDirectly + $documentsInDocumentPool;
    }
public function getDocuments ( array $ idList , $ callable = null ) { $ idListToFindDirectly = $ idList ; // try to egt document from pool if enabled $ documentsInDocumentPool = array ( ) ; if ( $ this -> isDocumentPoolEnabled ( ) && ! $ callable ) { $ documentsInDocumentPool = $ this -> getDocumentsFromDocumentPool ( $ idList ) ; if ( count ( $ documentsInDocumentPool ) === count ( $ idList ) ) { return $ documentsInDocumentPool ; } // skip ids already found in pool $ idListToFindDirectly = array_diff_key ( array_map ( 'strval' , $ idList ) , array_keys ( $ documentsInDocumentPool ) ) ; } // get documents directly $ cursor = $ this -> find ( ) ; if ( is_callable ( $ callable ) ) { call_user_func ( $ callable , $ cursor ) ; } $ documentsGettingDirectly = $ cursor -> byIdList ( $ idListToFindDirectly ) -> findAll ( ) ; if ( empty ( $ documentsGettingDirectly ) ) { return $ documentsInDocumentPool ? $ documentsInDocumentPool : array ( ) ; } if ( $ this -> isDocumentPoolEnabled ( ) ) { $ this -> addDocumentsToDocumentPool ( $ documentsGettingDirectly ) ; } return $ documentsGettingDirectly + $ documentsInDocumentPool ; }
Get documents by list of id

@param array $idList list of ids
@param callable $callable cursor callable used to configure cursor

@return Document[]
Get documents by list of id