From: Sébastien CHAZALLET Date: Fri, 16 Nov 2012 10:22:06 +0000 (+0100) Subject: Rajout de la gestion des formulaires dans \Custom X-Git-Url: http://git.inspyration.org/?p=zf2.biz%2Fgalerie.git;a=commitdiff_plain;h=590d9e5f7f81b81a4a62fb0795e029ef91441e60 Rajout de la gestion des formulaires dans \Custom --- diff --git a/vendor/zf2biz/Custom/Form/AbstractForm.php b/vendor/zf2biz/Custom/Form/AbstractForm.php new file mode 100644 index 0000000..f7f5249 --- /dev/null +++ b/vendor/zf2biz/Custom/Form/AbstractForm.php @@ -0,0 +1,98 @@ +_translator && $this->_translator_enabled) { + return $this->_translator->translate($k, $this->_textDomain); + } + return $k; + } + + + + + protected function addElement($name, $type='text', $label=null, $attributes=array(), $options=array()) + { + if ($type) { + $attributes['type' = $type + } + if ($label) { + $options['label'] = $label; + } + $params = array('name' => $name); + if ($attributes) { + $params['attributes'] = $attributes; + } + if ($options) { + $params['options'] = $options; + } + $this->add($params); + } + + + + + public function setTranslator(Translator $translator = null, $textDomain = null) + { + $this->_translator = $translator; + $this->_textDomain = $textDomain; + } + + public function getTranslator() + { + return $this->_translator; + } + + public function hasTranslator() + { + return $this->_translator !== null; + } + + public function setTranslatorEnabled($enabled = true) + { + $this->_translator_enabled = $enabed; + } + + public function isTranslatorEnabled() + { + return $this->_translator_enabled; + } + + public function setTranslatorTextDomain($textDomain = 'default') + { + $this->_textDomain = $textDomain; + } + + public function getTranslatorTextDomain() + { + return $this->_textDomain; + } + + + protected function setMethod($method='post') + { + $this->setAttribute('method', $method); + } + +} diff --git a/vendor/zf2biz/Custom/Model/Entity.php b/vendor/zf2biz/Custom/Model/Entity.php index 7788491..f261e5a 100644 --- a/vendor/zf2biz/Custom/Model/Entity.php +++ b/vendor/zf2biz/Custom/Model/Entity.php @@ -1,9 +1,19 @@ columns as $col) { @@ -23,6 +33,14 @@ class Entity return $result; } + public function getArrayCopy() { + $result = array(); + foreach($this->columns as $col) { + $result[$col] = $this->$col; + } + return $result; + } + public function toUpdatableArray() { $result = array(); foreach($this->updatable_columns as $col) { @@ -38,4 +56,39 @@ class Entity } return $result; } + + + + public function setInputFilter(InputFilterInterface $inputfilter) + { + $this->inputFilter = $inputFilter; + } + + public function getInputFilter() + { + if (!$this->inputFilter) { + $this->setDefaultInputFilter(); + } + return $this->inputFilter; + } + + protected function setDefaultInputFilter() + { + $inputFilter = new InputFilter; + $factory = new InputFactory; + + for ($this->getDefaultInputFilterArrays() as $params) { + $inputFilter->add($factory->createInput($params)) + } + $this->inputFilter = $inputFilter; + + return $this->inputFilter; + + } + + protected function getDefaultInputFilterArrays() + { + return array(); + } + }