web/lib/Zend/Serializer.php
changeset 807 877f952ae2bd
parent 207 621fa6caec0c
child 1230 68c69c656a2c
equal deleted inserted replaced
805:5e7a0fedabdf 807:877f952ae2bd
    12  * obtain it through the world-wide-web, please send an email
    12  * obtain it through the world-wide-web, please send an email
    13  * to license@zend.com so we can send you a copy immediately.
    13  * to license@zend.com so we can send you a copy immediately.
    14  *
    14  *
    15  * @category   Zend
    15  * @category   Zend
    16  * @package    Zend_Serializer
    16  * @package    Zend_Serializer
    17  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
    17  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    18  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    18  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    19  * @version    $Id: Serializer.php 20574 2010-01-24 17:39:14Z mabe $
    19  * @version    $Id: Serializer.php 24593 2012-01-05 20:35:02Z matthew $
    20  */
    20  */
    21 
    21 
    22 /** @see Zend_Loader_PluginLoader */
    22 /** @see Zend_Loader_PluginLoader */
    23 require_once 'Zend/Loader/PluginLoader.php';
    23 require_once 'Zend/Loader/PluginLoader.php';
    24 
    24 
    25 /**
    25 /**
    26  * @category   Zend
    26  * @category   Zend
    27  * @package    Zend_Serializer
    27  * @package    Zend_Serializer
    28  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
    28  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    29  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    29  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    30  */
    30  */
    31 class Zend_Serializer
    31 class Zend_Serializer
    32 {
    32 {
    33     /**
    33     /**
    49      *
    49      *
    50      * @param string|Zend_Serializer_Adapter_AdapterInterface $adapterName Name of the adapter class
    50      * @param string|Zend_Serializer_Adapter_AdapterInterface $adapterName Name of the adapter class
    51      * @param array |Zend_Config $opts Serializer options
    51      * @param array |Zend_Config $opts Serializer options
    52      * @return Zend_Serializer_Adapter_AdapterInterface
    52      * @return Zend_Serializer_Adapter_AdapterInterface
    53      */
    53      */
    54     public static function factory($adapterName, $opts = array()) 
    54     public static function factory($adapterName, $opts = array())
    55     {
    55     {
    56         if ($adapterName instanceof Zend_Serializer_Adapter_AdapterInterface) {
    56         if ($adapterName instanceof Zend_Serializer_Adapter_AdapterInterface) {
    57             return $adapterName; // $adapterName is already an adapter object
    57             return $adapterName; // $adapterName is already an adapter object
    58         }
    58         }
    59 
    59 
    78     /**
    78     /**
    79      * Get the adapter plugin loader.
    79      * Get the adapter plugin loader.
    80      *
    80      *
    81      * @return Zend_Loader_PluginLoader
    81      * @return Zend_Loader_PluginLoader
    82      */
    82      */
    83     public static function getAdapterLoader() 
    83     public static function getAdapterLoader()
    84     {
    84     {
    85         if (self::$_adapterLoader === null) {
    85         if (self::$_adapterLoader === null) {
    86             self::$_adapterLoader = self::_getDefaultAdapterLoader();
    86             self::$_adapterLoader = self::_getDefaultAdapterLoader();
    87         }
    87         }
    88         return self::$_adapterLoader;
    88         return self::$_adapterLoader;
    92      * Change the adapter plugin load.
    92      * Change the adapter plugin load.
    93      *
    93      *
    94      * @param  Zend_Loader_PluginLoader $pluginLoader
    94      * @param  Zend_Loader_PluginLoader $pluginLoader
    95      * @return void
    95      * @return void
    96      */
    96      */
    97     public static function setAdapterLoader(Zend_Loader_PluginLoader $pluginLoader) 
    97     public static function setAdapterLoader(Zend_Loader_PluginLoader $pluginLoader)
    98     {
    98     {
    99         self::$_adapterLoader = $pluginLoader;
    99         self::$_adapterLoader = $pluginLoader;
   100     }
   100     }
   101     
   101 
   102     /**
   102     /**
   103      * Resets the internal adapter plugin loader
   103      * Resets the internal adapter plugin loader
   104      *
   104      *
   105      * @return Zend_Loader_PluginLoader
   105      * @return Zend_Loader_PluginLoader
   106      */
   106      */
   107     public static function resetAdapterLoader()
   107     public static function resetAdapterLoader()
   108     {
   108     {
   109         self::$_adapterLoader = self::_getDefaultAdapterLoader();
   109         self::$_adapterLoader = self::_getDefaultAdapterLoader();
   110         return self::$_adapterLoader;
   110         return self::$_adapterLoader;
   111     }
   111     }
   112     
   112 
   113     /**
   113     /**
   114      * Returns a default adapter plugin loader
   114      * Returns a default adapter plugin loader
   115      *
   115      *
   116      * @return Zend_Loader_PluginLoader
   116      * @return Zend_Loader_PluginLoader
   117      */
   117      */
   126      * Change the default adapter.
   126      * Change the default adapter.
   127      *
   127      *
   128      * @param string|Zend_Serializer_Adapter_AdapterInterface $adapter
   128      * @param string|Zend_Serializer_Adapter_AdapterInterface $adapter
   129      * @param array|Zend_Config $options
   129      * @param array|Zend_Config $options
   130      */
   130      */
   131     public static function setDefaultAdapter($adapter, $options = array()) 
   131     public static function setDefaultAdapter($adapter, $options = array())
   132     {
   132     {
   133         self::$_defaultAdapter = self::factory($adapter, $options);
   133         self::$_defaultAdapter = self::factory($adapter, $options);
   134     }
   134     }
   135 
   135 
   136     /**
   136     /**
   137      * Get the default adapter.
   137      * Get the default adapter.
   138      *
   138      *
   139      * @return Zend_Serializer_Adapter_AdapterInterface
   139      * @return Zend_Serializer_Adapter_AdapterInterface
   140      */
   140      */
   141     public static function getDefaultAdapter() 
   141     public static function getDefaultAdapter()
   142     {
   142     {
   143         if (!self::$_defaultAdapter instanceof Zend_Serializer_Adapter_AdapterInterface) {
   143         if (!self::$_defaultAdapter instanceof Zend_Serializer_Adapter_AdapterInterface) {
   144             self::setDefaultAdapter(self::$_defaultAdapter);
   144             self::setDefaultAdapter(self::$_defaultAdapter);
   145         }
   145         }
   146         return self::$_defaultAdapter;
   146         return self::$_defaultAdapter;
   152      * @param mixed $value
   152      * @param mixed $value
   153      * @param array $options
   153      * @param array $options
   154      * @return string
   154      * @return string
   155      * @throws Zend_Serializer_Exception
   155      * @throws Zend_Serializer_Exception
   156      */
   156      */
   157     public static function serialize($value, array $options = array()) 
   157     public static function serialize($value, array $options = array())
   158     {
   158     {
   159         if (isset($options['adapter'])) {
   159         if (isset($options['adapter'])) {
   160             $adapter = self::factory($options['adapter']);
   160             $adapter = self::factory($options['adapter']);
   161             unset($options['adapter']);
   161             unset($options['adapter']);
   162         } else {
   162         } else {
   172      * @param string $serialized
   172      * @param string $serialized
   173      * @param array $options
   173      * @param array $options
   174      * @return mixed
   174      * @return mixed
   175      * @throws Zend_Serializer_Exception
   175      * @throws Zend_Serializer_Exception
   176      */
   176      */
   177     public static function unserialize($serialized, array $options = array()) 
   177     public static function unserialize($serialized, array $options = array())
   178     {
   178     {
   179         if (isset($options['adapter'])) {
   179         if (isset($options['adapter'])) {
   180             $adapter = self::factory($options['adapter']);
   180             $adapter = self::factory($options['adapter']);
   181             unset($options['adapter']);
   181             unset($options['adapter']);
   182         } else {
   182         } else {