From 9b1a10b8659a0e47aa5c38a1c720abf3628c0e2a Mon Sep 17 00:00:00 2001 From: Alec Smecher Date: Wed, 2 Oct 2019 16:07:11 -0400 Subject: [PATCH] pkp/pkp-lib#5122 Support Iterator pattern for DAOResultFactories --- classes/publication/PublicationDAO.inc.php | 4 +++- classes/services/GalleyService.inc.php | 4 ++-- classes/services/IssueService.inc.php | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/classes/publication/PublicationDAO.inc.php b/classes/publication/PublicationDAO.inc.php index 459af541696..0b678b6d7b6 100644 --- a/classes/publication/PublicationDAO.inc.php +++ b/classes/publication/PublicationDAO.inc.php @@ -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; } } diff --git a/classes/services/GalleyService.inc.php b/classes/services/GalleyService.inc.php index 908e44d99c3..7cb10f52d5d 100644 --- a/classes/services/GalleyService.inc.php +++ b/classes/services/GalleyService.inc.php @@ -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); @@ -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(); } /** diff --git a/classes/services/IssueService.inc.php b/classes/services/IssueService.inc.php index 4c050ced87a..36b22b61b28 100644 --- a/classes/services/IssueService.inc.php +++ b/classes/services/IssueService.inc.php @@ -52,7 +52,7 @@ public function get($issueId) { * @option string orderDirection * } * - * @return array + * @return Iterator */ public function getMany($args = array()) { $issueListQB = $this->_getQueryBuilder($args); @@ -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(); } /**