equal
deleted
inserted
replaced
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 * @subpackage Adapter |
17 * @subpackage Adapter |
18 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
18 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
19 * @license http://framework.zend.com/license/new-bsd New BSD License |
19 * @license http://framework.zend.com/license/new-bsd New BSD License |
20 * @version $Id: AdapterAbstract.php 20574 2010-01-24 17:39:14Z mabe $ |
20 * @version $Id: AdapterAbstract.php 24593 2012-01-05 20:35:02Z matthew $ |
21 */ |
21 */ |
22 |
22 |
23 /** @see Zend_Serializer_Adapter_AdapterInterface */ |
23 /** @see Zend_Serializer_Adapter_AdapterInterface */ |
24 require_once 'Zend/Serializer/Adapter/AdapterInterface.php'; |
24 require_once 'Zend/Serializer/Adapter/AdapterInterface.php'; |
25 |
25 |
26 /** |
26 /** |
27 * @category Zend |
27 * @category Zend |
28 * @package Zend_Serializer |
28 * @package Zend_Serializer |
29 * @subpackage Adapter |
29 * @subpackage Adapter |
30 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
30 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
31 * @license http://framework.zend.com/license/new-bsd New BSD License |
31 * @license http://framework.zend.com/license/new-bsd New BSD License |
32 */ |
32 */ |
33 abstract class Zend_Serializer_Adapter_AdapterAbstract implements Zend_Serializer_Adapter_AdapterInterface |
33 abstract class Zend_Serializer_Adapter_AdapterAbstract implements Zend_Serializer_Adapter_AdapterInterface |
34 { |
34 { |
35 /** |
35 /** |
42 /** |
42 /** |
43 * Constructor |
43 * Constructor |
44 * |
44 * |
45 * @param array|Zend_Config $opts Serializer options |
45 * @param array|Zend_Config $opts Serializer options |
46 */ |
46 */ |
47 public function __construct($opts = array()) |
47 public function __construct($opts = array()) |
48 { |
48 { |
49 $this->setOptions($opts); |
49 $this->setOptions($opts); |
50 } |
50 } |
51 |
51 |
52 /** |
52 /** |
53 * Set serializer options |
53 * Set serializer options |
54 * |
54 * |
55 * @param array|Zend_Config $opts Serializer options |
55 * @param array|Zend_Config $opts Serializer options |
56 * @return Zend_Serializer_Adapter_AdapterAbstract |
56 * @return Zend_Serializer_Adapter_AdapterAbstract |
57 */ |
57 */ |
58 public function setOptions($opts) |
58 public function setOptions($opts) |
59 { |
59 { |
60 if ($opts instanceof Zend_Config) { |
60 if ($opts instanceof Zend_Config) { |
61 $opts = $opts->toArray(); |
61 $opts = $opts->toArray(); |
62 } else { |
62 } else { |
63 $opts = (array) $opts; |
63 $opts = (array) $opts; |
74 * |
74 * |
75 * @param string $name Option name |
75 * @param string $name Option name |
76 * @param mixed $value Option value |
76 * @param mixed $value Option value |
77 * @return Zend_Serializer_Adapter_AdapterAbstract |
77 * @return Zend_Serializer_Adapter_AdapterAbstract |
78 */ |
78 */ |
79 public function setOption($name, $value) |
79 public function setOption($name, $value) |
80 { |
80 { |
81 $this->_options[(string) $name] = $value; |
81 $this->_options[(string) $name] = $value; |
82 return $this; |
82 return $this; |
83 } |
83 } |
84 |
84 |
85 /** |
85 /** |
86 * Get serializer options |
86 * Get serializer options |
87 * |
87 * |
88 * @return array |
88 * @return array |
89 */ |
89 */ |
90 public function getOptions() |
90 public function getOptions() |
91 { |
91 { |
92 return $this->_options; |
92 return $this->_options; |
93 } |
93 } |
94 |
94 |
95 /** |
95 /** |
97 * |
97 * |
98 * @param string $name |
98 * @param string $name |
99 * @return mixed |
99 * @return mixed |
100 * @throws Zend_Serializer_Exception |
100 * @throws Zend_Serializer_Exception |
101 */ |
101 */ |
102 public function getOption($name) |
102 public function getOption($name) |
103 { |
103 { |
104 $name = (string) $name; |
104 $name = (string) $name; |
105 if (!array_key_exists($name, $this->_options)) { |
105 if (!array_key_exists($name, $this->_options)) { |
106 require_once 'Zend/Serializer/Exception.php'; |
106 require_once 'Zend/Serializer/Exception.php'; |
107 throw new Zend_Serializer_Exception('Unknown option name "'.$name.'"'); |
107 throw new Zend_Serializer_Exception('Unknown option name "'.$name.'"'); |