/** * 读取内容 * * @return mixed */ public function read() { if (!file_exists($this->_path)) { touch($this->_path); } $content = file_get_contents($this->_path); try { $data = Zend_Serializer::unserialize($content); } catch (Zend_Serializer_Exception $e) { $data = $content; } return $data; }
public function getOauthObject($path) { $resource = Mage::getSingleton('core/resource'); $read = $resource->getConnection('twitterreader_read'); $query = 'SELECT `value` FROM `' . $resource->getTableName('core/config_data') . '` WHERE `path` = \'' . $path . '\''; $object = $read->fetchOne($query); if ($object) { $object = stripslashes($object); try { $object = Zend_Serializer::unserialize($object); } catch (Exception $e) { Mage::register('twitterreader_problem', 1); $object = false; } } return $object; }
public function testUnserializeSpecificAdapter() { $adapter = new Zend_Serializer_Adapter_Json(); $value = '"test"'; $expected = $adapter->unserialize($value); $this->assertEquals($expected, Zend_Serializer::unserialize($value, array('adapter' => $adapter))); }