toArray(); } if (isset($options['options'])) { unset($options['options']); } $unknownOptions = array(); foreach ((array) $options as $key => $value) { $method = 'set' . self::_normalizeKey($key); if (method_exists($object, $method)) { $object->$method($value); } else { $unknownOptions[$key] = $value; } } return $unknownOptions; } public static function getConstructorOptions($object) { $config = Qs_Config::getByInstance($object); /** @var $constructorOptions Zend_Config */ /** @var $options Zend_Config */ if (null !== ($constructorOptions = $config->get('__constructorOptions')) && null !== ($options = $constructorOptions->get(get_class($object))) ) { return $options->toArray(); } return []; } public static function mergeConstructorOptions($object, $options = array()) { /** @var $options Zend_Config */ if ($options instanceof Zend_Config) { $options = $options->toArray(); } return Qs_Array::mergeRecursive($options, self::getConstructorOptions($object)); } public static function setConstructorOptions($object, $options = array()) { self::setOptions($object, self::mergeConstructorOptions($object, $options)); } protected static function _normalizeKey($key) { $option = str_replace('_', ' ', strtolower($key)); $option = str_replace(' ', '', ucwords($option)); return $option; } }