b374k
m1n1 1.01
Apache/2.4.41 (Ubuntu)
Linux vmi616275.contaboserver.net 5.4.0-84-generic #94-Ubuntu SMP Thu Aug 26 20:27:37 UTC 2021 x86_64
uid=33(www-data) gid=33(www-data) groups=33(www-data)
server ip : 62.171.164.128 | your ip : 127.0.0.1
safemode OFF
 >  / home / a / home / dev2.destoffenstraat.com / vendor / magento / framework / Model / ResourceModel /
Filename/home/a/home/dev2.destoffenstraat.com/vendor/magento/framework/Model/ResourceModel/Iterator.php
Size2.25 kb
Permissionrw-r--r--
Ownerroot : root
Create time21-Aug-2025 12:26
Last modified07-Jan-2021 21:08
Last accessed23-Aug-2025 05:31
Actionsedit | rename | delete | download (gzip)
Viewtext | code | image
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

/**
* Active record implementation
*/
namespace Magento\Framework\Model\ResourceModel;

use Magento\Framework\DB\Adapter\AdapterInterface;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Phrase;

class Iterator extends \Magento\Framework\DataObject
{
/**
* Walk over records fetched from query one by one using callback function
*
* @param \Zend_Db_Statement_Interface|\Magento\Framework\DB\Select|string $query
* @param array|string $callbacks
* @param array $args
* @param AdapterInterface $connection
* @return \Magento\Framework\Model\ResourceModel\Iterator
*/
public function walk($query, array $callbacks, array $args = [], $connection = null)
{
$stmt = $this->_getStatement($query, $connection);
$args['idx'] = 0;
while ($row = $stmt->fetch()) {
$args['row'] = $row;
foreach ($callbacks as $callback) {
$result = call_user_func($callback, $args);
if (!empty($result)) {
$args = array_merge($args, (array)$result);
}
}
$args['idx']++;
}

return $this;
}

/**
* Fetch Zend statement instance
*
* @param \Zend_Db_Statement_Interface|\Magento\Framework\DB\Select|string $query
* @param AdapterInterface $connection
* @return \Zend_Db_Statement_Interface
* @throws LocalizedException
*/
protected function _getStatement($query, AdapterInterface $connection = null)
{
if ($query instanceof \Zend_Db_Statement_Interface) {
return $query;
}

if ($query instanceof \Zend_Db_Select) {
return $query->query();
}

if (is_string($query)) {
if (!$connection instanceof AdapterInterface) {
throw new LocalizedException(
new Phrase('The connection is invalid. Verify the connection and try again.')
);
}
return $connection->query($query);
}

throw new LocalizedException(new Phrase('The query is invalid. Verify the query and try again.'));
}
}