Skip to content

Commit

Permalink
pkp/pkp-lib#5122 Support Iterator pattern for DAOResultFactories
Browse files Browse the repository at this point in the history
  • Loading branch information
asmecher authored and ajnyga committed Nov 17, 2019
1 parent df5422f commit 9b1a10b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 3 additions & 1 deletion classes/publication/PublicationDAO.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ class PublicationDAO extends PKPPublicationDAO {
*/
public function _fromRow($primaryRow) {
$publication = parent::_fromRow($primaryRow);
$publication->setData('galleys', Services::get('galley')->getMany(['publicationIds' => $publication->getId()]));
$publication->setData('galleys', iterator_to_array(
Services::get('galley')->getMany(['publicationIds' => $publication->getId()])
));
return $publication;
}
}
4 changes: 2 additions & 2 deletions classes/services/GalleyService.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function get($galleyId) {
* @option int count
* @option int offset
* }
* @return array
* @return Iterator
*/
public function getMany($args = []) {
$galleyQB = $this->_getQueryBuilder($args);
Expand All @@ -53,7 +53,7 @@ public function getMany($args = []) {
$result = $galleyDao->retrieveRange($galleyQO->toSql(), $galleyQO->getBindings(), $range);
$queryResults = new DAOResultFactory($result, $galleyDao, '_fromRow');

return $queryResults->toArray();
return $queryResults->toIterator();
}

/**
Expand Down
4 changes: 2 additions & 2 deletions classes/services/IssueService.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function get($issueId) {
* @option string orderDirection
* }
*
* @return array
* @return Iterator
*/
public function getMany($args = array()) {
$issueListQB = $this->_getQueryBuilder($args);
Expand All @@ -62,7 +62,7 @@ public function getMany($args = array()) {
$result = $issueDao->retrieveRange($issueListQO->toSql(), $issueListQO->getBindings(), $range);
$queryResults = new DAOResultFactory($result, $issueDao, '_fromRow');

return $queryResults->toArray();
return $queryResults->toIterator();
}

/**
Expand Down

0 comments on commit 9b1a10b

Please sign in to comment.