From 8ca6cc32b2c789a3149861159ad258f2cb9491e3 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 14:39:39 +0200 Subject: Adding upstream version 2.11.4. Signed-off-by: Daniel Baumann --- library/vendor/Zend/Form/Decorator/Abstract.php | 251 ++++++++++++++++++++++++ 1 file changed, 251 insertions(+) create mode 100644 library/vendor/Zend/Form/Decorator/Abstract.php (limited to 'library/vendor/Zend/Form/Decorator/Abstract.php') diff --git a/library/vendor/Zend/Form/Decorator/Abstract.php b/library/vendor/Zend/Form/Decorator/Abstract.php new file mode 100644 index 0000000..93c5a05 --- /dev/null +++ b/library/vendor/Zend/Form/Decorator/Abstract.php @@ -0,0 +1,251 @@ +setOptions($options); + } elseif ($options instanceof Zend_Config) { + $this->setConfig($options); + } + } + + /** + * Set options + * + * @param array $options + * @return Zend_Form_Decorator_Abstract + */ + public function setOptions(array $options) + { + $this->_options = $options; + return $this; + } + + /** + * Set options from config object + * + * @param Zend_Config $config + * @return Zend_Form_Decorator_Abstract + */ + public function setConfig(Zend_Config $config) + { + return $this->setOptions($config->toArray()); + } + + /** + * Set option + * + * @param string $key + * @param mixed $value + * @return Zend_Form_Decorator_Abstract + */ + public function setOption($key, $value) + { + $this->_options[(string) $key] = $value; + return $this; + } + + /** + * Get option + * + * @param string $key + * @return mixed + */ + public function getOption($key) + { + $key = (string) $key; + if (isset($this->_options[$key])) { + return $this->_options[$key]; + } + + return null; + } + + /** + * Retrieve options + * + * @return array + */ + public function getOptions() + { + return $this->_options; + } + + /** + * Remove single option + * + * @param mixed $key + * @return void + */ + public function removeOption($key) + { + if (null !== $this->getOption($key)) { + unset($this->_options[$key]); + return true; + } + + return false; + } + + /** + * Clear all options + * + * @return Zend_Form_Decorator_Abstract + */ + public function clearOptions() + { + $this->_options = array(); + return $this; + } + + /** + * Set current form element + * + * @param Zend_Form_Element|Zend_Form $element + * @return Zend_Form_Decorator_Abstract + * @throws Zend_Form_Decorator_Exception on invalid element type + */ + public function setElement($element) + { + if ((!$element instanceof Zend_Form_Element) + && (!$element instanceof Zend_Form) + && (!$element instanceof Zend_Form_DisplayGroup)) + { + throw new Zend_Form_Decorator_Exception('Invalid element type passed to decorator'); + } + + $this->_element = $element; + return $this; + } + + /** + * Retrieve current element + * + * @return Zend_Form_Element|Zend_Form + */ + public function getElement() + { + return $this->_element; + } + + /** + * Determine if decorator should append or prepend content + * + * @return string + */ + public function getPlacement() + { + $placement = $this->_placement; + if (null !== ($placementOpt = $this->getOption('placement'))) { + $placementOpt = strtoupper($placementOpt); + switch ($placementOpt) { + case self::APPEND: + case self::PREPEND: + $placement = $this->_placement = $placementOpt; + break; + case false: + $placement = $this->_placement = null; + break; + default: + break; + } + $this->removeOption('placement'); + } + + return $placement; + } + + /** + * Retrieve separator to use between old and new content + * + * @return string + */ + public function getSeparator() + { + $separator = $this->_separator; + if (null !== ($separatorOpt = $this->getOption('separator'))) { + $separator = $this->_separator = (string) $separatorOpt; + $this->removeOption('separator'); + } + return $separator; + } + + /** + * Decorate content and/or element + * + * @param string $content + * @return string + * @throws Zend_Form_Decorator_Exception when unimplemented + */ + public function render($content) + { + throw new Zend_Form_Decorator_Exception('render() not implemented'); + } +} -- cgit v1.2.3