Skip to content
Snippets Groups Projects
Commit 7f40d031 authored by Patrick Barroca's avatar Patrick Barroca :grin:
Browse files

dev #48349 : fix rt

parent 246ca5cc
Branches
Tags
2 merge requests!2334Master,!2104Dev#48349 ux versionning
Pipeline #1089 passed with stage
in 12 minutes and 10 seconds
...@@ -226,39 +226,11 @@ class ZendAfi_Form extends Zend_Form { ...@@ -226,39 +226,11 @@ class ZendAfi_Form extends Zend_Form {
public function beVersionCompare($datas) { public function beVersionCompare($datas) {
foreach($this->getElements() as $element) (new ZendAfi_Form_VersionHelper())->prepare($this, $datas);
$element->setDecorators([$this->_versionCompareDecoratorFor($element, $datas)]);
return $this; return $this;
} }
protected function _versionCompareDecoratorFor($element, $datas) {
$class_name = $this->_specificClassFor($element,
'ZendAfi_Form_Decorator_VersionCompare');
return new $class_name(['datas' => $datas]);
}
protected function _specificClassFor($element, $base_class) {
try {
$specific = $base_class . '_' . $this->_getElementType($element);
Zend_Loader::loadClass($specific);
$base_class = $specific;
} catch(Exception $e) {
// couldn't load, will default to generic class name
}
return $base_class;
}
protected function _getElementType($element) {
$parts = explode('_', get_class($element));
return end($parts);
}
public static function keepValueParamName($id='') { public static function keepValueParamName($id='') {
return 'keepValueOf_'.$id; return 'keepValueOf_'.$id;
} }
......
<?php
/**
* Copyright (c) 2012-2017, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* BOKEH is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class ZendAfi_Form_VersionHelper {
public function prepare($form, $datas) {
foreach($form->getElements() as $element)
$this->_prepareElement($element, $datas);
}
protected function _prepareElement($element, $datas) {
$element->setDecorators([$this->_decoratorFor($element, $datas)]);
}
protected function _decoratorFor($element, $datas) {
$class_name = $this->_classFor($element, 'ZendAfi_Form_Decorator_VersionCompare');
return new $class_name(['datas' => $datas]);
}
protected function _ClassFor($element, $base_class) {
try {
$specific = $base_class . '_' . $this->_getElementType($element);
Zend_Loader::loadClass($specific);
$base_class = $specific;
} catch(Exception $e) {
// couldn't load, will default to generic class name
}
return $base_class;
}
protected function _getElementType($element) {
$parts = explode('_', get_class($element));
return end($parts);
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment