TPageStateFormatter is a utility class to transform the page state
into and from a string that can be properly saved in persistent storage.
Depending on the {@link TPage::getEnableStateValidation() EnableStateValidation}
and {@link TPage::getEnableStateEncryption() EnableStateEncryption},
TPageStateFormatter may do HMAC validation and encryption to prevent
the state data from being tampered or viewed.
The private keys and hashing/encryption methods are determined by
{@link TApplication::getSecurityManager() SecurityManager}.
/** * Loads page state from hidden fields. * @return mixed the restored state * @throws THttpException if page state is corrupted */ public function load() { if (($data = TPageStateFormatter::unserialize($this->_page, $this->_page->getRequestClientState())) !== null) { return $data; } else { throw new THttpException(400, 'pagestatepersister_pagestate_corrupted'); } }
/** * Loads page state from session. * @return mixed the restored state * @throws THttpException if page state is corrupted */ public function load() { if (($timestamp = TPageStateFormatter::unserialize($this->_page, $this->_page->getRequestClientState())) !== null) { $session = $this->_page->getSession(); $session->open(); $key = self::STATE_SESSION_KEY . $timestamp; if (($data = $session->itemAt($key)) !== null) { return unserialize($data); } } throw new THttpException(400, 'sessionpagestatepersister_pagestate_corrupted'); }
/** * Loads page state from cache. * @return mixed the restored state * @throws THttpException if page state is corrupted */ public function load() { if (($timestamp = TPageStateFormatter::unserialize($this->_page, $this->_page->getRequestClientState())) !== null) { $key = $this->calculateKey($timestamp); if (($data = $this->getCache()->get($key)) !== false) { return $data; } } throw new THttpException(400, 'cachepagestatepersister_pagestate_corrupted'); }