This repository has been archived on 2024-12-01. You can view files and clone it, but cannot push or open issues or pull requests.
factuges_web/yii/framework/web/CHttpSessionIterator.php
david e93adbdd4e - Importación inicial
- Registro, activación y entrada de usuarios


git-svn-id: https://192.168.0.254/svn/Rodax.factuges_web/trunk@2 e455b18d-f7fe-5245-9c43-e2c35af70a32
2013-06-13 16:04:48 +00:00

92 lines
1.9 KiB
PHP

<?php
/**
* CHttpSessionIterator class file.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/
* @copyright Copyright &copy; 2008-2011 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
/**
* CHttpSessionIterator implements an interator for {@link CHttpSession}.
*
* It allows CHttpSession to return a new iterator for traversing the session variables.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @package system.web
* @since 1.0
*/
class CHttpSessionIterator implements Iterator
{
/**
* @var array list of keys in the map
*/
private $_keys;
/**
* @var mixed current key
*/
private $_key;
/**
* Constructor.
* @param array the data to be iterated through
*/
public function __construct()
{
$this->_keys=array_keys($_SESSION);
}
/**
* Rewinds internal array pointer.
* This method is required by the interface Iterator.
*/
public function rewind()
{
$this->_key=reset($this->_keys);
}
/**
* Returns the key of the current array element.
* This method is required by the interface Iterator.
* @return mixed the key of the current array element
*/
public function key()
{
return $this->_key;
}
/**
* Returns the current array element.
* This method is required by the interface Iterator.
* @return mixed the current array element
*/
public function current()
{
return isset($_SESSION[$this->_key])?$_SESSION[$this->_key]:null;
}
/**
* Moves the internal pointer to the next array element.
* This method is required by the interface Iterator.
*/
public function next()
{
do
{
$this->_key=next($this->_keys);
}
while(!isset($_SESSION[$this->_key]) && $this->_key!==false);
}
/**
* Returns whether there is an element at current position.
* This method is required by the interface Iterator.
* @return boolean
*/
public function valid()
{
return $this->_key!==false;
}
}