本文整理汇总了PHP中Prado::unserialize方法的典型用法代码示例。如果您正苦于以下问题:PHP Prado::unserialize方法的具体用法?PHP Prado::unserialize怎么用?PHP Prado::unserialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Prado
的用法示例。
在下文中一共展示了Prado::unserialize方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: load
public function load()
{
if (($cache = $this->getApplication()->getCache()) !== null && ($value = $cache->get(self::CACHE_NAME)) !== false) {
return Prado::unserialize($value);
} else {
if (($content = @file_get_contents($this->getStateFilePath())) !== false) {
return Prado::unserialize($content);
} else {
return null;
}
}
}
示例2: unserialize
/**
* @param TPage
* @param string serialized data
* @return mixed unserialized state data, null if data is corrupted
*/
public static function unserialize($page, $data)
{
$str = base64_decode($data);
if ($str === '') {
return null;
}
if ($str !== false) {
$sm = $page->getApplication()->getSecurityManager();
if ($page->getEnableStateEncryption()) {
$str = $sm->decrypt($str);
}
if ($page->getEnableStateCompression() && extension_loaded('zlib')) {
$str = @gzuncompress($str);
}
if ($page->getEnableStateValidation()) {
if (($str = $sm->validateData($str)) !== false) {
return Prado::unserialize($str);
}
} else {
return Prado::unserialize($str);
}
}
return null;
}
示例3: initApplication
protected function initApplication()
{
if ($this->_configFile !== null) {
if ($this->_cacheFile === null || @filemtime($this->_cacheFile) < filemtime($this->_configFile)) {
$config = new TApplicationConfiguration();
$config->loadFromFile($this->_configFile);
if ($this->_cacheFile !== null) {
file_put_contents($this->_cacheFile, Prado::serialize($config), LOCK_EX);
}
} else {
$config = Prado::unserialize(file_get_contents($this->_cacheFile));
}
$this->applyConfiguration($config, false);
}
if (($serviceID = $this->getRequest()->resolveRequest(array_keys($this->_services))) === null) {
$serviceID = $this->getPageServiceID();
}
$this->startService($serviceID);
}
示例4: getValue
/**
* Retrieves a value from cache with a specified key.
* This is the implementation of the method declared in the parent class.
* @param string a unique key identifying the cached value
* @return string the value stored in cache, false if the value is not in the cache or expired.
*/
protected function getValue($key)
{
$sql = 'SELECT value FROM ' . self::CACHE_TABLE . ' WHERE key=\'' . $key . '\' AND (expire=0 OR expire>' . time() . ') LIMIT 1';
if (($ret = $this->_db->query($sql)) != false && ($row = $ret->fetch(SQLITE_ASSOC)) !== false) {
return Prado::unserialize($row['value']);
} else {
return false;
}
}
示例5: getValue
/**
* Retrieves a value from cache with a specified key.
* This is the implementation of the method declared in the parent class.
* @param string a unique key identifying the cached value
* @return string the value stored in cache, false if the value is not in the cache or expired.
*/
protected function getValue($key)
{
if (!$this->_cacheInitialized) {
$this->initializeCache();
}
try {
$sql = 'SELECT value FROM ' . $this->_cacheTable . ' WHERE itemkey=\'' . $key . '\' AND (expire=0 OR expire>' . time() . ') ORDER BY expire DESC';
$command = $this->getDbConnection()->createCommand($sql);
return Prado::unserialize($command->queryScalar());
} catch (Exception $e) {
$this->initializeCache(true);
return Prado::unserialize($command->queryScalar());
}
}