From e8b60312037e54c34a06d6f57d7c21946cf3cd1f Mon Sep 17 00:00:00 2001 From: xue <> Date: Wed, 28 Dec 2005 20:17:54 +0000 Subject: Modified the way to access application singleton. IService and IModule interfaces are also adjusted accordingly. --- framework/Web/UI/TPageStatePersister.php | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'framework/Web/UI/TPageStatePersister.php') diff --git a/framework/Web/UI/TPageStatePersister.php b/framework/Web/UI/TPageStatePersister.php index 07e1eba1..988a2938 100644 --- a/framework/Web/UI/TPageStatePersister.php +++ b/framework/Web/UI/TPageStatePersister.php @@ -2,20 +2,17 @@ class TPageStatePersister extends TModule implements IStatePersister { - private $_application; private $_privateKey=null; /** * Initializes the service. * This method is required by IModule interface. - * @param TApplication application * @param TXmlElement module configuration */ - public function init($application, $config) + public function init($config=null) { - parent::init($application,$config); - $this->_application=$application; - $application->getService()->setPageStatePersister($this); + parent::init($config); + $this->getService()->setPageStatePersister($this); } public function save($state) @@ -26,12 +23,12 @@ class TPageStatePersister extends TModule implements IStatePersister $data=gzcompress($hmac.$data); else $data=$hmac.$data; - $this->_application->getService()->getRequestedPage()->getClientScript()->registerHiddenField(TPage::FIELD_PAGESTATE,base64_encode($data)); + $this->getService()->getRequestedPage()->getClientScript()->registerHiddenField(TPage::FIELD_PAGESTATE,base64_encode($data)); } public function load() { - $str=base64_decode($this->_application->getRequest()->getItems()->itemAt(TPage::FIELD_PAGESTATE)); + $str=base64_decode($this->getApplication()->getRequest()->getItems()->itemAt(TPage::FIELD_PAGESTATE)); if($str==='') return null; if(extension_loaded('zlib')) @@ -60,10 +57,10 @@ class TPageStatePersister extends TModule implements IStatePersister { if(empty($this->_privateKey)) { - if(($this->_privateKey=$this->_application->getGlobalState('prado:pagestatepersister:privatekey'))===null) + if(($this->_privateKey=$this->getApplication()->getGlobalState('prado:pagestatepersister:privatekey'))===null) { $this->_privateKey=$this->generatePrivateKey(); - $this->_application->setGlobalState('prado:pagestatepersister:privatekey',$this->_privateKey,null); + $this->getApplication()->setGlobalState('prado:pagestatepersister:privatekey',$this->_privateKey,null); } } return $this->_privateKey; -- cgit v1.2.3