/** * {@inheritdoc} */ public function parse(FeedInterface $feed, FetcherResultInterface $fetcher_result, StateInterface $state) { $feed_config = $feed->getConfigurationFor($this); if (!filesize($fetcher_result->getFilePath())) { throw new EmptyFeedException(); } // Load and configure parser. $parser = CsvFileParser::createFromFilePath($fetcher_result->getFilePath())->setDelimiter($feed_config['delimiter'] === 'TAB' ? "\t" : $feed_config['delimiter'])->setHasHeader(!$feed_config['no_headers'])->setStartByte((int) $state->pointer); // Wrap parser in a limit iterator. $parser = new \LimitIterator($parser, 0, $this->configuration['line_limit']); $header = !$feed_config['no_headers'] ? $parser->getHeader() : []; $result = new ParserResult(); foreach ($parser as $row) { $item = new DynamicItem(); foreach ($row as $delta => $cell) { $key = isset($header[$delta]) ? $header[$delta] : $delta; $item->set($key, $cell); } $result->addItem($item); } // Report progress. $state->total = filesize($fetcher_result->getFilePath()); $state->pointer = $parser->lastLinePos(); $state->progress($state->total, $state->pointer); return $result; }
function testLimitIterator() { $this->assertEquals(3, $this->_domainObjectCollection->getTotalRecordCount()); $limitIT = new LimitIterator($this->_domainObjectCollection, 1, 2); $limitIT->rewind(); $this->assertEquals($this->_domObject2, $limitIT->current()); $limitIT->next(); $this->assertEquals($this->_domObject3, $limitIT->current()); }
/** * Returns a workspace list by json * * It can be filtered by by keyword. */ public function actionSearchJson() { $keyword = Yii::app()->request->getParam('keyword', ""); // guid of user/workspace $page = (int) Yii::app()->request->getParam('page', 1); // current page (pagination) $limit = (int) Yii::app()->request->getParam('limit', HSetting::Get('paginationSize')); // current page (pagination) $keyword = Yii::app()->input->stripClean($keyword); $hitCount = 0; $query = "model:Space "; if (strlen($keyword) > 2) { // Include Keyword if (strpos($keyword, "@") === false) { $keyword = str_replace(".", "", $keyword); $query .= "AND (title:" . $keyword . "* OR tags:" . $keyword . "*)"; } } //, $limit, $page $hits = new ArrayObject(HSearch::getInstance()->Find($query)); $hitCount = count($hits); // Limit Hits $hits = new LimitIterator($hits->getIterator(), ($page - 1) * $limit, $limit); $json = array(); #$json['totalHits'] = $hitCount; #$json['limit'] = $limit; #$results = array(); foreach ($hits as $hit) { $doc = $hit->getDocument(); $model = $doc->getField("model")->value; if ($model == "Space") { $workspaceId = $doc->getField('pk')->value; $workspace = Space::model()->findByPk($workspaceId); if ($workspace != null) { $wsInfo = array(); $wsInfo['guid'] = $workspace->guid; $wsInfo['title'] = CHtml::encode($workspace->name); $wsInfo['tags'] = CHtml::encode($workspace->tags); $wsInfo['image'] = $workspace->getProfileImage()->getUrl(); $wsInfo['link'] = $workspace->getUrl(); #$results[] = $wsInfo; $json[] = $wsInfo; } else { Yii::log("Could not load workspace with id " . $userId . " from search index!", CLogger::LEVEL_ERROR); } } else { Yii::log("Got no workspace hit from search index!", CLogger::LEVEL_ERROR); } } #$json['results'] = $results; print CJSON::encode($json); Yii::app()->end(); }
public function getNext() { if ($count = count($this->queues)) { $it = new \ArrayIterator($this->queues); $it = new \InfiniteIterator($it); $it = new \LimitIterator($it, $this->nextPos, $count); foreach ($it as $queue) { if ($task = $queue->pop()) { $this->nextPos = ($it->getPosition() + 1) % $count; return $task; } } } return false; }
/** * Constructor. * * @param \Iterator $iterator Source data * @param integer $offset Offset (Optional) * @param integer $count Maximum item count (Optional) * @param integer $mode Result counting mode * @throws \InvalidArgumentException Inner iterator is not countable */ public function __construct(\Iterator $iterator, int $offset = 0, int $count = -1, int $mode = self::MODE_PASS) { if (!$iterator instanceof \Countable) { throw new \InvalidArgumentException('Supplied iterator must be countable'); } parent::__construct($iterator, $offset, $count); $this->offset = $offset; $this->count = $count; $this->mode = $mode; }
<?php $it = new LimitIterator(new ArrayIterator(array(1, 2, 3, 4)), 1, 2); foreach ($it as $k => $v) { echo "{$k}=>{$v}\n"; var_dump($it->getPosition()); } try { $it->seek(0); } catch (OutOfBoundsException $e) { echo $e->getMessage() . "\n"; } $it->seek(2); var_dump($it->current()); try { $it->seek(3); } catch (OutOfBoundsException $e) { echo $e->getMessage() . "\n"; } $it->next(); var_dump($it->valid()); ?> ===DONE=== <?php exit(0);
/** * Hook the posts 'where' and search Lucene * We modify the search SQL to return the posts found from Lucene * * @param string $where WordPress SQL * @return string SQL **/ function posts_where( $where ) { $_GET['s'] = get_query_var( 's' ); $this->terms = array( $_GET['s'] ); $lucene = $this->open(); if ( $lucene ) { $modules = Search_Module_Factory::running(); $where = 'AND 1=2'; // Nothing was found try { $this->terms = array_filter( preg_split( '/[\s,]+/', trim( get_query_var( 's' ) ) ) ); $this->query = new Zend_Search_Lucene_Search_Query_Boolean(); $have_comments = false; // Add queries for all the modules foreach ( (array)$modules AS $module ) { if ( $module->is_comment() ) $have_comments = true; $sub = Zend_Search_Lucene_Search_QueryParser::parse( get_query_var( 's' ), get_option( 'blog_charset' ) ); $this->query->addSubquery( $sub, true ); if ( isset( $_GET[$module->field_name()] ) ) { $value = $module->field_value( $_GET[$module->field_name()] ); // XXX remove any braces from and value if ( $value !== false ) { $sub = Zend_Search_Lucene_Search_QueryParser::parse( $module->field_name().':('.$value.')', get_option( 'blog_charset' ) ); $this->query->addSubquery( $sub, true ); } } } // Add restrictions for status $this->query->addSubquery( Zend_Search_Lucene_Search_QueryParser::parse( $this->get_restricted_posts() ), true ); // Do the Lucene query $hits = new ArrayObject( $lucene->find( $this->query ) ); if ( count( $hits ) > 0 ) { global $wpdb; $page = get_query_var( 'paged' ) ? get_query_var( 'paged' ) - 1 : 0; $start = get_query_var( 'posts_per_page' ) * ( $page ); $this->total_hits = count( $hits ); if ( $have_comments ) $hits = new LimitIterator( $hits->getIterator(), 0 ); else $hits = new LimitIterator( $hits->getIterator(), $start ); foreach ( $hits AS $hit ) { $this->post_ids[] = $hit->post_id; if ( !$have_comments && count( $this->post_ids ) >= get_query_var( 'posts_per_page' ) ) break; } if ( $have_comments ) { $this->post_ids = array_unique( $this->post_ids ); $this->total_hits = count( $this->post_ids ); $this->post_ids = array_slice( $this->post_ids, $start, get_query_var( 'posts_per_page' ) ); } $where = "AND ID IN (".implode( ',', $this->post_ids ).')'; add_filter( 'the_posts', array( &$this, 'the_posts' ) ); } } catch( Zend_Search_Lucene_Exception $e ) { } } return $where; }
public function find($keyword, array $options) { $options = $this->setDefaultFindOptions($options); $index = $this->getIndex(); $keyword = str_replace(array('*', '?', '_', '$'), ' ', mb_strtolower($keyword, 'utf-8')); if (!isset($options['sortField']) || $options['sortField'] == "") { $hits = new \ArrayObject($index->find($this->buildQuery($keyword, $options))); } else { $hits = new \ArrayObject($index->find($this->buildQuery($keyword, $options), $options['sortField'])); } $resultSet = new SearchResultSet(); $resultSet->total = count($hits); $resultSet->pageSize = $options['pageSize']; $resultSet->page = $options['page']; $hits = new \LimitIterator($hits->getIterator(), ($options['page'] - 1) * $options['pageSize'], $options['pageSize']); foreach ($hits as $hit) { $document = $hit->getDocument(); $result = new SearchResult(); $result->model = $document->getField('model')->getUtf8Value(); $result->pk = $document->getField('pk')->getUtf8Value(); $result->type = $document->getField('type')->getUtf8Value(); $resultSet->results[] = $result; } return $resultSet; }
} } class SeekableNumericArrayIterator extends NumericArrayIterator implements SeekableIterator { public function seek($index) { if ($index < count($this->a)) { $this->i = $index; } echo __METHOD__ . '(' . $index . ")\n"; } } $a = array(1, 2, 3, 4, 5); foreach (new LimitIterator(new NumericArrayIterator($a), 1, 3) as $v) { print "{$v}\n"; } echo "===SEEKABLE===\n"; $a = array(1, 2, 3, 4, 5); foreach (new LimitIterator(new SeekableNumericArrayIterator($a), 1, 3) as $v) { print "{$v}\n"; } echo "===SEEKING===\n"; $a = array(1, 2, 3, 4, 5); $l = new LimitIterator(new SeekableNumericArrayIterator($a)); for ($i = 1; $i < 4; $i++) { $l->seek($i); print $l->current() . "\n"; } ?> ===DONE===
/** * SearchAction * * Modes: normal for full page, quick as partial for lightbox */ public function actionIndex() { // Get Parameters $keyword = Yii::app()->request->getParam('keyword', ""); $spaceGuid = Yii::app()->request->getParam('sguid', ""); $mode = Yii::app()->request->getParam('mode', "normal"); $page = (int) Yii::app()->request->getParam('page', 1); // current page (pagination) // Cleanup $keyword = Yii::app()->input->stripClean($keyword); $spaceGuid = Yii::app()->input->stripClean($spaceGuid); if ($mode != 'quick') { $mode = "normal"; } $limit = HSetting::Get('paginationSize'); // Show Hits $hitCount = 0; // Total Hit Count $query = ""; // Lucene Query $append = " AND (model:User OR model:Space)"; // Appends for Lucene Query $moreResults = false; // Indicates if there are more hits $results = array(); // Quick Search shows always 1 if ($mode == 'quick') { $limit = 5; } // Load also Space if requested $currentSpace = null; if ($spaceGuid) { $currentSpace = Space::model()->findByAttributes(array('guid' => $spaceGuid)); } /* * $index = new Zend_Search_Lucene_Interface_MultiSearcher(); * $index->addIndex(Zend_Search_Lucene::open('search/index1')); * $index->addIndex(Zend_Search_Lucene::open('search/index2')); * $index->find('someSearchQuery'); */ // Do Search if ($keyword != "") { if ($currentSpace != null) { $append = " AND (model:User OR model:Space OR (belongsToType:Space AND belongsToId:" . $currentSpace->id . "))"; } $hits = new ArrayObject(HSearch::getInstance()->Find($keyword . "* " . $append)); $hitCount = count($hits); // Limit Hits $hits = new LimitIterator($hits->getIterator(), ($page - 1) * $limit, $limit); if ($hitCount > $limit) { $moreResults = true; } // Build Results Array foreach ($hits as $hit) { $doc = $hit->getDocument(); $model = $doc->getField('model')->value; $pk = $doc->getField('pk')->value; $object = $model::model()->findByPk($pk); $results[] = $object->getSearchResult(); } } // Create Pagination Class $pages = new CPagination($hitCount); $pages->setPageSize($limit); $_GET['keyword'] = $keyword; // Fix for post var if ($mode == 'quick') { $this->renderPartial('quick', array('keyword' => $keyword, 'results' => $results, 'spaceGuid' => $spaceGuid, 'moreResults' => $moreResults, 'hitCount' => $hitCount)); } else { $this->render('index', array('keyword' => $keyword, 'results' => $results, 'spaceGuid' => $spaceGuid, 'moreResults' => $moreResults, 'pages' => $pages, 'pageSize' => $limit, 'hitCount' => $hitCount)); } }
{ public function seek($index) { if ($index < count($this->a)) { $this->i = $index; } echo __METHOD__ . '(' . $index . ")\n"; } } $a = array(1, 2, 3, 4, 5); $it = new LimitIterator(new NumericArrayIterator($a), 1, 3); foreach ($it as $v) { print $v . ' is ' . ($it->greaterThan(2) ? 'greater than 2' : 'less than or equal 2') . "\n"; } echo "===SEEKABLE===\n"; $a = array(1, 2, 3, 4, 5); $it = new LimitIterator(new SeekableNumericArrayIterator($a), 1, 3); foreach ($it as $v) { print $v . ' is ' . ($it->greaterThan(2) ? 'greater than 2' : 'less than or equal 2') . "\n"; } echo "===STACKED===\n"; echo "Shows '2 is greater than 2' because the test is actually done with the current value which is 3.\n"; $a = array(1, 2, 3, 4, 5); $it = new CachingIterator(new LimitIterator(new SeekableNumericArrayIterator($a), 1, 3)); foreach ($it as $v) { print $v . ' is ' . ($it->greaterThan(2) ? 'greater than 2' : 'less than or equal 2') . "\n"; } ?> ===DONE=== <?php exit(0);
function current() { return call_user_func($this->options['itemClass'] . "::getByID", parent::current()); }
/** * Find one file and return. * * @param string $path The directory path. * @param mixed $condition Finding condition, that can be a string, a regex or a callback function. * Callback example: * <code> * function($current, $key, $iterator) * { * return @preg_match('^Foo', $current->getFilename()) && ! $iterator->isDot(); * } * </code> * @param boolean $recursive True to resursive. * * @return \SplFileInfo Finded file info object. * * @since 2.0 */ public static function findOne($path, $condition, $recursive = false) { $iterator = new \LimitIterator(static::find($path, $condition, $recursive), 0, 1); $iterator->rewind(); return $iterator->current(); }
/** * Space Section of directory * * Provides a list of all visible spaces. * * @todo Dont pass lucene hits to view, build user array inside of action */ public function actionSpaces() { $keyword = Yii::app()->request->getParam('keyword', ""); // guid of user/workspace $page = (int) Yii::app()->request->getParam('page', 1); // current page (pagination) $keyword = Yii::app()->input->stripClean($keyword); $hits = array(); $query = ""; $hitCount = 0; $sortField = null; $query = "model:Space"; if ($keyword != "") { $query .= " AND " . $keyword; } else { $sortField = 'title'; } //$hits = new ArrayObject( // HSearch::getInstance()->Find($query, HSetting::Get('paginationSize'), $page // )); $hits = new ArrayObject(HSearch::getInstance()->Find($query, $sortField)); $hitCount = count($hits); // Limit Hits $hits = new LimitIterator($hits->getIterator(), ($page - 1) * HSetting::Get('paginationSize'), HSetting::Get('paginationSize')); // Create Pagination Class $pages = new CPagination($hitCount); $pages->setPageSize(HSetting::Get('paginationSize')); $_GET['keyword'] = $keyword; // Fix for post var // Add Meber Statistic Sidebar Yii::app()->interceptor->preattachEventHandler('DirectorySidebarWidget', 'onInit', function ($event) { $event->sender->addWidget('application.modules_core.directory.widgets.NewSpacesWidget', array(), array('sortOrder' => 10)); $event->sender->addWidget('application.modules_core.directory.widgets.SpaceStatisticsWidget', array(), array('sortOrder' => 20)); }); $this->render('spaces', array('keyword' => $keyword, 'hits' => $hits, 'pages' => $pages, 'hitCount' => $hitCount, 'pageSize' => HSetting::Get('paginationSize'))); }
/** * Find one file and return. * * @param mixed $condition Finding condition, that can be a string, a regex or a callback function. * Callback example: * <code> * function($current, $key, $iterator) * { * return @preg_match('^Foo', $current->getFilename()) && ! $iterator->isDot(); * } * </code> * @param boolean $recursive True to resursive. * * @return \SplFileInfo Finded file info object. * * @since 1.0 */ public function find($condition, $recursive = false) { $iterator = new \LimitIterator($this->findAll($condition, $recursive), 0, 1); $iterator->rewind(); return $iterator->current(); }
public function getLatestEpisode() { $iterator = new \LimitIterator(new PastEpisodeFilterIterator(new \ArrayIterator($this->buildEpisodesList())), 0, 1); $iterator->rewind(); return $iterator->current(); }
<?php $array = array("Hello", array("World"), array("How", array("are", "you")), "doing?"); // Create our Recursive data structure $recursiveIterator = new RecursiveArrayIterator($array); // Create our recursive iterator $recursiveIteratorIterator = new RecursiveIteratorIterator($recursiveIterator); // Create a limit iterator $limitIterator = new LimitIterator($recursiveIteratorIterator, 2, 5); // Iterate foreach ($limitIterator as $key => $value) { $innerIterator = $limitIterator->getInnerIterator(); echo "Depth: " . $innerIterator->getDepth() . PHP_EOL; echo "Key: " . $key . PHP_EOL; echo "Value: " . $value . PHP_EOL; }
<?php $xmlstring = <<<XML <?xml version = "1.0" encoding="windows-1251"?> <person> \t<name>Иван</name> \t<name>Вася</name> \t<name>Петя</name> \t<name>Джон</name> \t<name>Майк</name> \t<name>Лена</name> \t<name>Маша</name> \t<name>Даша</name> </person> XML; $offset = 3; $limit = 2; $it = new LimitIterator(new SimpleXMLIterator($xmlstring), $offset, $limit); foreach ($it as $r) { echo $it->key() . ' -- ' . $it->current() . '<br />'; }
session_start(); if (isset($_GET['reset'])) { session_unset(); session_destroy(); } if (!isset($_SESSION['collection'])) { $_SESSION['collection'] = new LivreIterator(); $_SESSION['debut'] = 1; $_SESSION['taillePage'] = 10; } if (isset($_GET['suivant'])) { $_SESSION['debut'] += $_GET['suivant'] * $_SESSION['taillePage']; } echo "<p>**** " . count($_SESSION['collection']) . " ****</p>"; echo "<p>**** " . $_SESSION['debut'] . " -- " . $_SESSION['taillePage'] . " ****</p>"; $pageCourante = new LimitIterator($_SESSION['collection'], $_SESSION['debut'] - 1, $_SESSION['taillePage']); echo "<ul>"; foreach ($pageCourante as $val) { echo "<li>"; echo $pageCourante->key() . " " . $val->toJSON(); echo "</li> "; } echo "</ul>"; $decalageFirst = (int) (-1 * $_SESSION['debut'] / $_SESSION['taillePage']); $decalageLast = (int) ((count($_SESSION['collection']) - $_SESSION['debut']) / $_SESSION['taillePage']); $decalagePrev = $_SESSION['debut'] == 1 ? 0 : -1; $decalageNext = $_SESSION['debut'] + $_SESSION['taillePage'] > count($_SESSION['collection']) ? 0 : 1; $urlFirst = $_SERVER['PHP_SELF'] . "?suivant=" . $decalageFirst; $urlPrev = $_SERVER['PHP_SELF'] . "?suivant=" . $decalagePrev; $urlNext = $_SERVER['PHP_SELF'] . "?suivant=" . $decalageNext; $urlLast = $_SERVER['PHP_SELF'] . "?suivant=" . $decalageLast;
} } } catch (Exception $e) { echo $e->getMessage(); } echo '----------------------------------- CachingIterator END ---------------------------------', '<br />'; echo '--------------------------------- LimitIterator END-----------------------------------', '<br />'; /** * LimitIterator 遍历一个Iterator的限定子集 * 在__construct有两个可选参数:offset 和 count */ $array = array('apple', 'banana', 'cherry', 'damson', 'elderberry'); $fruits = new ArrayIterator($array); $offset = 3; $count = 2; $limitIt = new LimitIterator($fruits, $offset, $count); // 如果增加了offset,那么只有两个数,但是rewind时,节点值不会变成0,而是被截取的值offset。 // getPosition 获得当前节点的位置 $limitIt->rewind(); var_dump($limitIt->getPosition()); foreach ($limitIt as $item) { echo $item, '<br />'; } echo '--------------------------------- LimitIterator START-----------------------------------', '<br />'; echo '----------------------------------- SplFileObject END ---------------------------------', '<br />'; /** * SplFileObject 对文本文件进行遍历 */ $file = '/data/www/test.php'; $fileIt = new SplFileObject($file); // 遍历获得所有的文本,按行遍历
/** * JSON Search interface for Mentioning */ public function actionMentioning() { $results = array(); $keyword = Yii::app()->request->getParam('keyword', ""); $keyword = Yii::app()->input->stripClean(trim($keyword)); if (strlen($keyword) >= 3) { $hits = new ArrayObject(HSearch::getInstance()->Find($keyword . "* AND (model:User OR model:Space)")); $hitCount = count($hits); $hits = new LimitIterator($hits->getIterator(), 0, 10); foreach ($hits as $hit) { $doc = $hit->getDocument(); $model = $doc->getField('model')->value; $pk = $doc->getField('pk')->value; $object = $model::model()->findByPk($pk); if ($object !== null && $object instanceof HActiveRecordContentContainer) { $result = array(); $result['guid'] = $object->guid; if ($object instanceof Space) { $result['name'] = CHtml::encode($object->name); $result['type'] = 's'; } elseif ($object instanceof User) { $result['name'] = CHtml::encode($object->displayName); $result['type'] = 'u'; } $result['image'] = $object->getProfileImage()->getUrl(); $result['link'] = $object->getUrl(); $results[] = $result; } } } print CJSON::encode($results); }
/** * search function * searches the index * * @param mixed $Model * @param mixed $query * @param int $limit * @param int $page * @access public * @return void */ function search(&$Model, $query, $limit = 20, $page = 1) { // open the index if (!$this->open_index($Model)) { return false; } try { // set the default encoding Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding('utf-8'); // zend search results limiting (We will use the LimitIterator) // we can use it for some maximum value like 1000 if its likely that there could be more results Zend_Search_Lucene::setResultSetLimit(1000); // set the parser default operator to AND Zend_Search_Lucene_Search_QueryParser::setDefaultOperator(Zend_Search_Lucene_Search_QueryParser::B_AND); // utf-8 num analyzer Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num_CaseInsensitive()); // parse the query $Query = Zend_Search_Lucene_Search_QueryParser::parse($query); $Terms = $Query->getQueryTerms(); foreach ($Terms as $Term) { $this->terms[] = $Term->text; } // do the search $Hits = new ArrayObject($this->Index->find($Query)); } catch (Zend_Search_Lucene_Exception $e) { $this->log("Zend_Search_Lucene error: " . $e->getMessage(), 'searchable'); } $this->hits_count = count($Hits); if (!count($Hits)) { return null; } $Hits = new LimitIterator($Hits->getIterator(), ($page - 1) * $limit, $limit); $results = array(); foreach ($Hits as $Hit) { $Document = $Hit->getDocument(); $fields = $Document->getFieldNames(); $result = array(); foreach ($fields as $field) { $result['Result'][$field] = $Document->{$field}; } $results[] = $result; } return $results; }
{ echo __METHOD__ . "\n"; return $this->i; } public function current() { echo __METHOD__ . "\n"; return $this->a[$this->i]; } public function next() { echo __METHOD__ . "\n"; $this->i++; } } $it = new LimitIterator(new NumericArrayIterator(array(12, 25, 42, 56))); foreach ($it as $k => $v) { var_dump($k); var_dump($v); } echo "===SEEK===\n"; $it->seek(2); echo "===LOOP===\n"; foreach (new NoRewindIterator($it) as $k => $v) { var_dump($k); var_dump($v); } ?> ===DONE=== <?php exit(0);
private $remoteDir = false; private $regexpPattern = false; private $regexpReplacement = false; private $connection = false; private $connectionType = false; private $connectionPort = false; private $connectionTimeout = 10; private $arItems = array(); } /* * ***************************************************************************** */ date_default_timezone_set('Europe/Moscow'); error_reporting(E_ERROR); $config = ['indexFile' => 'files10.csv', 'typeconn' => FTP_INTERFACE, 'host' => 'demo.your-host.ru', 'user' => 'demo', 'password' => 'your-password', 'start_dir' => "www/demo.your-host.ru"]; $task = new Task(); $task->setLocalDir('temp'); $task->setRemoteDir($config['start_dir']); $task->connect($config['host'], $config['user'], $config['password'], FTP_PORT, FTP_INTERFACE); $task->setRegexp('|[\\s\\n\\r]+|', null); if ($task->checkConnection()) { System::showMessage("\n\n * * * Read the index file ({$config['indexFile']}) and downloadable files"); $index = new LimitIterator(new SplFileObject($config["indexFile"]), 0, 1); while (!$index->eof()) { if ($remoteFile = $index->fgetcsv()[0]) { $localFile = $task->add($remoteFile); } } System::showMessage("\n\n * * * Create backups and perform replacing in files"); $task->replacement(); } $task->disconnect(); /* * ***************************************************************************** */
/** * Construct a Zend\Paginator\SerializableLimitIterator * * @param Iterator $it Iterator to limit (must be serializable by un-/serialize) * @param int $offset Offset to first element * @param int $count Maximum number of elements to show or -1 for all * @see LimitIterator::__construct */ public function __construct(Iterator $it, $offset = 0, $count = -1) { parent::__construct($it, $offset, $count); $this->offset = $offset; $this->count = $count; }
<?php $a = array(1, 2, 3); $lt = new LimitIterator(new ArrayIterator($a)); $lt->seek(1, 1); // Should throw a warning as seek expects only 1 argument