本文整理汇总了PHP中ArrayObject::getIterator方法的典型用法代码示例。如果您正苦于以下问题:PHP ArrayObject::getIterator方法的具体用法?PHP ArrayObject::getIterator怎么用?PHP ArrayObject::getIterator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArrayObject
的用法示例。
在下文中一共展示了ArrayObject::getIterator方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getIterator
public function getIterator()
{
if ($this->cacheIsFilled !== TRUE) {
$this->fillCache();
}
return $this->instanceCache->getIterator();
}
示例2: clear
/**
* 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;
}
示例3: unEscapeParameters
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);
}
示例4: __construct
/**
* 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;
}
示例5: __construct
/**
* 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();
}
示例6: __construct
/**
* 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();
}
示例7: removePlayer
/**
* 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;
}
示例8: zipcodesUniqueValues
/**
* 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";
}
示例9: sentenceWrapper
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;
}
示例10: getIterator
public function getIterator()
{
if (!isset($this->iterator)) {
$this->iterator = parent::getIterator();
}
return $this->iterator;
}
示例11: getIterator
public function getIterator()
{
if (!isset($this->data)) {
$this->lazyInitialization();
}
return $this->data->getIterator();
}
示例12: add
/**
* 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;
}
}
}
示例13: getInputHtml
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));
}
示例14: getIterator
public function getIterator()
{
if (!$this->loaded) {
$this->load();
}
return parent::getIterator();
}
示例15: getSettingsHtml
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()));
}