public function getIterator() { if ($this->cacheIsFilled !== TRUE) { $this->fillCache(); } return $this->instanceCache->getIterator(); }
/** * Clear the Collection * * <ul> * * <li>Empties Collection Storage and References Storage</li> * <li>Redefine Collection Iterator</li> * * </ul> * * @return Next\Components\Iterator\AbstractCollection * Collection Object (Fluent Interface) */ public function clear() { $this->collection = new \ArrayObject(); $this->references = new \ArrayObject(); $this->iterator = $this->collection->getIterator(); return $this; }
public function unEscapeParameters($string) { if (!$this->parametersArray) { throw new \Exception('You try unescape string that not be escaped'); } $this->iterator = $this->parametersArray->getIterator(); return preg_replace_callback("|NotTranslatedString|", array($this, 'unEscapeParametersCallback'), $string); }
/** * Constructor * * @param int $total Total @ of results w/o pagination bounds * @param array $items An array of Resqee_Persistence_Item items */ public function __construct(Resqee_Persistence_SearchParams $params, $total = 0, array $items = array()) { $this->total = $total; $this->limit = $params->limit; $this->items = new ArrayObject($items); $this->iter = $this->items->getIterator(); $this->numPages = (int) ceil($total / $params->limit); $this->currentPage = (int) floor($params->offset / $params->limit) + 1; $this->lastIndex = $this->count() > 0; }
/** * Constructor * * @param $state * @param $template * @return void */ public function __construct($state, $template = null) { // When omitting, set the same name. if (!$template) { $template = $state; } $this->state = $state; $this->template = $template; $this->eventMap = new ArrayObject(array()); $this->eventMapIterator = $this->eventMap->getIterator(); }
/** * Constructs the TextIterator * * @param string $subject * @param integer $iteratorType The type of iterator * @throws \TYPO3\FLOW3\Error\Exception */ public function __construct($subject, $iteratorType = self::CHARACTER) { if ($iteratorType < 1 || $iteratorType > 6) { throw new \TYPO3\FLOW3\Error\Exception('Fatal error: Invalid iterator type in TextIterator constructor', 1210849014); } $this->iteratorType = $iteratorType; $this->subject = (string) $subject; $this->currentPosition = 0; $this->iteratorCache = new \ArrayObject(); $this->iteratorCacheIterator = $this->iteratorCache->getIterator(); $this->generateIteratorElements(); $this->iteratorCacheIterator->rewind(); $this->previousElement = $this->iteratorCacheIterator->current(); }
/** * Deletes player * @param $id */ public function removePlayer($id) { $x = 0; $i = $this->players->getIterator(); while ($i->valid()) { if ($i->current()->getID() == $id) { $i->offsetUnset($x); } $i->next(); $x++; } $i->rewind(); $this->iterator = $i; }
/** * Lee el archivo de codigos postales y crea un nuevo vector con valores unicos. * @throws Exception */ public function zipcodesUniqueValues() { $code = new ArrayObject(); $data = \helper\GeoHelper::readZipcodeFile($this->sources['path']['txt']['zipcode']); $zip = $data->getIterator(); while ($zip->valid()) { $content = $zip->current(); $code->append("{$content->offsetGet(0)}||"); $zip->next(); } $this->zipcodesBlocks = new ArrayObject(array_unique($code->getArrayCopy())); $iterator = $this->zipcodesBlocks->getIterator(); $dir = __DIR__ . '/test'; mkdir($dir, 0777); $file = bin2hex(openssl_random_pseudo_bytes(10)); $file = "{$dir}/zipcode_location_{$file}.txt"; $handle = fopen($file, 'w'); echo "[32m Creando el archivo {$file}\n"; while ($iterator->valid()) { fwrite($handle, "{$iterator->current()}\n"); $iterator->next(); } fclose($handle); echo "[33m Se ha terminado de crear el archivo.\n"; }
private function sentenceWrapper(SentenceUtil $sentence) { $it = $sentence->getBuildCommand()->getIterator(); $attr = null; $main = new \ArrayObject(); $append = new \ArrayObject(); while ($it->valid()) { if (Util::contains($it->current()->getClause(), "commandPrint") || Util::contains($it->current()->getClause(), "commandReguler")) { if ($attr == null) { $main->append($it->current()); } } else { //if contains neither then add to append commands $append->append($it->current()); } $it->next(); } foreach ($append->getIterator() as $a) { $main->append($a); } /* $it->rewind(); while ($it->valid()) { if (!Util::contains($it->current()->getClause(), "commandPrint") && !Util::contains($it->current()->getClause(), "commandReguler")) { } $it->next(); } */ return $main; }
public function getIterator() { if (!isset($this->iterator)) { $this->iterator = parent::getIterator(); } return $this->iterator; }
public function getIterator() { if (!isset($this->data)) { $this->lazyInitialization(); } return $this->data->getIterator(); }
/** * array object değeri add edilir * * @param \ArrayObject $ArrayObject * @param string $key * @param string $name * @return void */ public function add(\ArrayObject $ArrayObject, $key = null, $name = null) { $iterator = $ArrayObject->getIterator(); $this->num_rows = $iterator->count(); if ($key == null && $name == null) { while ($iterator->valid()) { $arr = $iterator->current(); $this->dataArr[] = ['id' => $arr, 'name' => $arr]; $iterator->next(); $this->error = false; } } else { $sonaEklenecek = array(); while ($iterator->valid()) { $arr = $iterator->current(); if ($this->getEnSonaEklenecekDeger() == null) { $this->dataArr[] = ['id' => $arr[$key], 'name' => trim($arr[$name])]; } else { $value = trim($arr[$name]); if ($this->getEnSonaEklenecekDeger() == $value) { $sonaEklenecek = ['id' => $arr[$key], 'name' => $value]; } else { $this->dataArr[] = ['id' => $arr[$key], 'name' => $value]; } } $iterator->next(); $this->error = false; } if (count($sonaEklenecek) != 0) { $this->dataArr[] = $sonaEklenecek; } } }
public function getInputHtml($name, $value) { // Get site templates path $templatesPath = $siteTemplatesPath = craft()->path->getSiteTemplatesPath(); // Check if the templates path is overriden by configuration // TODO: Normalize path $limitToSubfolder = craft()->config->get('templateselectSubfolder'); if ($limitToSubfolder) { $templatesPath = $templatesPath . rtrim($limitToSubfolder, '/') . '/'; } // Check if folder exists, or give error if (!IOHelper::folderExists($templatesPath)) { throw new \InvalidArgumentException('(Template Select) Folder doesn\'t exist: ' . $templatesPath); } // Get folder contents $templates = IOHelper::getFolderContents($templatesPath, TRUE); // Add placeholder for when there is no template selected $filteredTemplates = array('' => Craft::t('No template selected')); // Turn array into ArrayObject $templates = new \ArrayObject($templates); // Iterate over template list // * Remove full path // * Remove folders from list for ($list = $templates->getIterator(); $list->valid(); $list->next()) { $filename = $list->current(); $filename = str_replace($templatesPath, '', $filename); $filenameIncludingSubfolder = $limitToSubfolder ? $limitToSubfolder . $filename : $filename; $isTemplate = preg_match("/(.html|.twig)\$/u", $filename); if ($isTemplate) { $filteredTemplates[$filenameIncludingSubfolder] = $filename; } } // Render field return craft()->templates->render('_includes/forms/select', array('name' => $name, 'value' => $value, 'options' => $filteredTemplates)); }
public function getIterator() { if (!$this->loaded) { $this->load(); } return parent::getIterator(); }
public function getSettingsHtml() { $pluginSettings = craft()->plugins->getPlugin('placid')->getSettings(); // Get placid requests and send them to the widget settings $requests = craft()->placid_requests->findAllRequests(); $requestsArray = array('' => 'No request selected'); foreach ($requests as $request) { $requestsArray[$request->handle] = $request->name; } $templatesPath = craft()->path->getSiteTemplatesPath() . $pluginSettings->widgetTemplatesPath; $templates = IOHelper::getFolderContents($templatesPath, TRUE); $templatesArray = array('' => Craft::t('No template selected')); if (!$templates) { $templatesArray = array('' => 'Cannot find templates'); Craft::log('Cannot find templates in path "' . $templatesPath . '"', LogLevel::Error); } else { // Turn array into ArrayObject $templates = new \ArrayObject($templates); // Iterate over template list // * Remove full path // * Remove folders from list for ($list = $templates->getIterator(); $list->valid(); $list->next()) { $filename = $list->current(); $filename = str_replace($templatesPath, '', $filename); $filenameIncludingSubfolder = $filename; $isTemplate = preg_match("/(.html|.twig)\$/u", $filename); if ($isTemplate) { $templatesArray[$filenameIncludingSubfolder] = $filename; } } } return craft()->templates->render('placid/_widgets/request/settings', array('requests' => $requestsArray, 'templates' => $templatesArray, 'settings' => $this->getSettings())); }
/** * @param array $files * @param array $type * @return CallbackFilterIterator */ public function filterByType($files, array $type) { $filesObject = new \ArrayObject($files); $fileOperator = $this->filelib->getFileOperator(); $filteredFiles = array(); if (version_compare(phpversion(), '5.4.0') >= 0) { $filteredFiles = new \CallbackFilterIterator($filesObject->getIterator(), function ($current, $key) use($type, $fileOperator) { return in_array($fileOperator->getType($current), $type); }); } else { $filteredFiles = new XiCallbackFilterIterator($filesObject->getIterator(), function ($current, $key) use($type, $fileOperator) { return in_array($fileOperator->getType($current), $type); }); } return $filteredFiles; }
/** * Merges an Array Object in this one * * @param ArrayObject $array * @return void */ public function merge(ArrayObject $array) { $i = $array->getIterator(); while ($i->valid()) { $this->append($i->current()); $i->next(); } }
/** * 述語に基づいて値のシーケンスをフィルター処理します。 * * @param \ArrayObject $source フィルター処理するシーケンス * @param \Closure $predicate 各ソース要素が条件に当てはまるかどうかをテストする関数。 * この関数の 2 つ目のパラメーターは、ソース要素のインデックスを表します。 * * @return \ArrayObject 条件を満たす、入力シーケンスの要素を含むシーケンス */ public function whereOf(\ArrayObject $source, \Closure $predicate) : \ArrayObject { $filtering = new \ArrayObject([]); foreach ($source->getIterator() as $key => $value) { $predicate($value, $key) === true && $filtering->append($value); } return $filtering; }
/** * 指定された型に基づいてシーケンスの要素をフィルター処理します。 * * @param \ArrayObject $source フィルター処理する要素を含むシーケンス * @param string $type シーケンスの要素をフィルター処理する型の名前 * * @return \ArrayObject 入力シーケンスの各要素を指定された型にキャストした要素を格納するシーケンス。 * キャストに失敗した要素は含まれません。 */ public function ofTypeOf(\ArrayObject $source, string $type) : \ArrayObject { $dst = TCollection::emptyList(); foreach ($source->getIterator() as $key => $value) { is_scalar($value) === true && $dst->append(call_user_func(strtolower($type) . "val", $value)); } return $dst; }
/** * @covers ::<protected> * @covers ::get */ public function testDeepGet() { $cursorStub = new \ArrayObject(array((object) array('_id' => new MongoIdStub(1), 'nested' => array('deep' => array('deeper' => 1))))); $this->cursorStub = $cursorStub->getIterator(); $this->result = new \PHPixie\Database\Driver\Mongo\Result($this->cursorStub); $this->assertEquals(1, $this->result->get('nested.deep.deeper')); $this->assertEquals(null, $this->result->get('nested.deep.nope')); }
public function getResultsFound() { if ($this->results->count() > 0) { $result = $this->results->getIterator(); $responseJson = '['; while ($result->valid()) { $object = $this->buildObject($result->current()); $responseJson .= $object->toJSON() . ','; $result->next(); } $responseJson = substr($responseJson, 0, -1); $responseJson .= ']'; return $responseJson; } else { return null; } }
public function setValues(ArrayObject $values, $toDataset) { $itValues = $values->getIterator(); while ($itValues->valid()) { $this->setValue($itValues->current(), $toDataset); $itValues->next(); } }
public function processStates(ArrayObject $states) { // ArrayObject $statesItr = $states->getIterator(); for ($statesItr; $statesItr->valid(); $statesItr->next()) { echo $statesItr->key() . ' : ' . $statesItr->current() . PHP_EOL; } }
/** * @param ArrayObject $listOfData * @return HashMap */ public function groupDataValues(ArrayObject $listOfData) { $mapGrouped = new HashMap(); if ($listOfData->count() > 0) { $dataToGroup = $this->objectData($listOfData->offsetGet(0)); $list = $listOfData->getIterator(); $list2 = $listOfData->getIterator(); $dataAux = null; $i = 0; while ($list->valid()) { $auxList = $this->getDataOfSameTypeAndPutIntoList($list2, $dataToGroup, $dataAux); $this->changePointers($list, $list2, $dataAux, $dataToGroup); $this->changeDataToGroup($list, $dataToGroup); $this->groupIntoMap($mapGrouped, $auxList, $i); } } return $mapGrouped; }
public function filter_post_content_out($content) { preg_match_all('/<!-- file:(.*) -->/i', $content, $matches, PREG_PATTERN_ORDER); $matches_obj = new ArrayObject($matches[1]); for ($it = $matches_obj->getIterator(); $it->valid(); $it->next()) { $content = str_ireplace('<!-- file:' . $it->current() . ' -->', $this->embed_player($it->current()), $content); } return $content; }
/** * Constructor * * @param resource$result Resultset */ public function __construct($result) { $this->db = PMF_Db::getInstance(); $arrayObject = new ArrayObject(); while ($row = $this->db->fetch_assoc($result)) { $arrayObject[] = $row; } $this->iterator = $arrayObject->getIterator(); }
private function parse_entities() { $obj = new ArrayObject(parse_ini_file(pathinfo(__FILE__, PATHINFO_DIRNAME) . '/entities.ini')); $it = $obj->getIterator(); while ($it->valid()) { $this->html_entities['/&' . $it->key() . ';/'] = '&#' . $it->current() . ';'; $it->next(); } }
public function getIterator() { if (is_null($this->modified)) { $this->lazyInitialization(); } if (is_null($this->data)) { return new \ArrayIterator(array()); } return $this->data->getIterator(); }
/** * Cria o nó XML referente ao objeto. * @return string * @see XMLNode::createXMLNode() */ public function createXMLNode() { $root = $this->getRootNode(); $xml = ''; foreach ( $this->nodes->getIterator() as $node ) { $xml .= $node->createXMLNode(); } return sprintf( '<?xml version="1.0" encoding="UTF-8"?>%s<%s id="%s" versao="%s" xmlns="%s">%s</%s>' , PHP_EOL , $root , $this->getId() , $this->version , $this->getNamespace() , $xml , $root ); }
/** * 指定された条件が満たされる限り、シーケンスから要素を返します * * @param \ArrayObject $source 要素を返すシーケンス * @param \Closure $predicate 各要素が条件を満たしているかどうかをテストする関数 * * @return \ArrayObject 入力シーケンスの先頭の要素からテストに初めて合格しない要素の前に出現する要素までを含むシーケンス */ public function takeWhileOf(\ArrayObject $source, \Closure $predicate) : \ArrayObject { $taken = new \ArrayObject([]); foreach ($source->getIterator() as $key => $value) { if ($predicate($value) === false) { break; } $taken->append($value); } return $taken; }