From 01bc363ac789cfb9d644ce82a949da5cd7e1c220 Mon Sep 17 00:00:00 2001 From: xue <> Date: Tue, 31 Jan 2006 00:01:49 +0000 Subject: Modified TList and TMap implementation so that they can be more easily extended. --- framework/Web/THttpRequest.php | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) (limited to 'framework/Web/THttpRequest.php') diff --git a/framework/Web/THttpRequest.php b/framework/Web/THttpRequest.php index 2a3a35aa..ba626d07 100644 --- a/framework/Web/THttpRequest.php +++ b/framework/Web/THttpRequest.php @@ -140,7 +140,7 @@ class THttpRequest extends TMap implements IModule $_COOKIE=$this->stripSlashes($_COOKIE); } - $this->copyfrom(array_merge($_GET,$_POST)); + $this->copyFrom(array_merge($_GET,$_POST)); $this->_initialized=true; $this->getApplication()->setRequest($this); @@ -487,32 +487,38 @@ class THttpCookieCollection extends TList } /** - * Adds the cookie if owner of this collection is of THttpResponse. - * This method will be invoked whenever an item is added to the collection. + * Inserts an item at the specified position. + * This overrides the parent implementation by performing additional + * operations for each newly added THttpCookie object. + * @param integer the speicified position. + * @param mixed new item + * @throws TInvalidDataTypeException if the item to be inserted is not a THttpCookie object. */ - protected function addedItem($item) + public function insertAt($index,$item) { - if($this->_o instanceof THttpResponse) - $this->_o->addCookie($item); + if($item instanceof THttpCookie) + { + parent::insertAt($index,$item); + if($this->_o instanceof THttpResponse) + $this->_o->addCookie($item); + } + else + throw new TInvalidDataTypeException('authorizationrulecollection_authorizationrule_required'); } /** - * Removes the cookie if owner of this collection is of THttpResponse. - * This method will be invoked whenever an item is removed from the collection. + * Removes an item at the specified position. + * This overrides the parent implementation by performing additional + * cleanup work when removing a TCookie object. + * @param integer the index of the item to be removed. + * @return mixed the removed item. */ - protected function removedItem($item) + public function removeAt($index) { + $item=parent::removeAt($index); if($this->_o instanceof THttpResponse) $this->_o->removeCookie($item); - } - - /** - * Restricts acceptable item of this collection to THttpCookie. - * This method will be invoked whenever an item is to be added into the collection. - */ - protected function canAddItem($item) - { - return ($item instanceof THttpCookie); + return $item; } } -- cgit v1.2.3