File indexing completed on 2024-05-12 06:02:21
0001 <?php 0002 /** 0003 * Zend Framework 0004 * 0005 * LICENSE 0006 * 0007 * This source file is subject to the new BSD license that is bundled 0008 * with this package in the file LICENSE.txt. 0009 * It is also available through the world-wide-web at this URL: 0010 * http://framework.zend.com/license/new-bsd 0011 * If you did not receive a copy of the license and are unable to 0012 * obtain it through the world-wide-web, please send an email 0013 * to license@zend.com so we can send you a copy immediately. 0014 * 0015 * @category Zend 0016 * @package Zend_Config 0017 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0018 * @license http://framework.zend.com/license/new-bsd New BSD License 0019 * @version $Id$ 0020 */ 0021 0022 /** 0023 * @category Zend 0024 * @package Zend_Config 0025 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0026 * @license http://framework.zend.com/license/new-bsd New BSD License 0027 */ 0028 abstract class Zend_Config_Writer 0029 { 0030 /** 0031 * Option keys to skip when calling setOptions() 0032 * 0033 * @var array 0034 */ 0035 protected $_skipOptions = array( 0036 'options' 0037 ); 0038 0039 /** 0040 * Config object to write 0041 * 0042 * @var Zend_Config 0043 */ 0044 protected $_config = null; 0045 0046 /** 0047 * Create a new adapter 0048 * 0049 * $options can only be passed as array or be omitted 0050 * 0051 * @param null|array $options 0052 */ 0053 public function __construct(array $options = null) 0054 { 0055 if (is_array($options)) { 0056 $this->setOptions($options); 0057 } 0058 } 0059 0060 /** 0061 * Set options via a Zend_Config instance 0062 * 0063 * @param Zend_Config $config 0064 * @return Zend_Config_Writer 0065 */ 0066 public function setConfig(Zend_Config $config) 0067 { 0068 $this->_config = $config; 0069 0070 return $this; 0071 } 0072 0073 /** 0074 * Set options via an array 0075 * 0076 * @param array $options 0077 * @return Zend_Config_Writer 0078 */ 0079 public function setOptions(array $options) 0080 { 0081 foreach ($options as $key => $value) { 0082 if (in_array(strtolower($key), $this->_skipOptions)) { 0083 continue; 0084 } 0085 0086 $method = 'set' . ucfirst($key); 0087 if (method_exists($this, $method)) { 0088 $this->$method($value); 0089 } 0090 } 0091 0092 return $this; 0093 } 0094 0095 /** 0096 * Write a Zend_Config object to it's target 0097 * 0098 * @return void 0099 */ 0100 abstract public function write(); 0101 }