summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorxue <>2006-03-05 04:00:52 +0000
committerxue <>2006-03-05 04:00:52 +0000
commit8c0cc31021515bdc29a6c6ebc44e903acdb0430f (patch)
tree883749d34cef241cd1cadf3139e4fe5c2397fc69 /framework
parent7cd0bdea1d094485ae197fd80297791555c08d1c (diff)
Added name-based cookie retrieval.
Diffstat (limited to 'framework')
-rw-r--r--framework/Collections/TList.php5
-rw-r--r--framework/Web/THttpRequest.php18
2 files changed, 19 insertions, 4 deletions
diff --git a/framework/Collections/TList.php b/framework/Collections/TList.php
index 6dd2561b..244eab0f 100644
--- a/framework/Collections/TList.php
+++ b/framework/Collections/TList.php
@@ -298,10 +298,7 @@ class TList extends TComponent implements IteratorAggregate,ArrayAccess
*/
public function offsetGet($offset)
{
- if($offset>=0 && $offset<$this->_c)
- return $this->_d[$offset];
- else
- throw new TInvalidDataValueException('list_index_invalid',$offset);
+ return $this->itemAt($offset);
}
/**
diff --git a/framework/Web/THttpRequest.php b/framework/Web/THttpRequest.php
index 293c73f1..d3a8480a 100644
--- a/framework/Web/THttpRequest.php
+++ b/framework/Web/THttpRequest.php
@@ -681,6 +681,12 @@ class THttpRequest extends TApplicationComponent implements IteratorAggregate,Ar
* THttpCookieCollection class.
*
* THttpCookieCollection implements a collection class to store cookies.
+ * Besides using all functionalities from {@link TList}, you can also
+ * retrieve a cookie by its name using either {@link findCookieByName} or
+ * simply:
+ * <code>
+ * $cookie=$collection[$cookieName];
+ * </code>
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @version $Revision: $ $Date: $
@@ -739,6 +745,18 @@ class THttpCookieCollection extends TList
}
/**
+ * @param integer|string index of the cookie in the collection or the cookie's name
+ * @return THttpCookie the cookie found
+ */
+ public function itemAt($index)
+ {
+ if(is_integer($index))
+ return parent::itemAt($index);
+ else
+ return $this->findCookieByName($index);
+ }
+
+ /**
* Finds the cookie with the specified name.
* @param string the name of the cookie to be looked for
* @return THttpCookie the cookie, null if not found