ImportRowModifier: provide target_property...

...also adjust the related form

refs #11949
This commit is contained in:
Thomas Gelf 2016-07-20 13:41:16 +02:00
parent 38bf19eb92
commit d90bb05ca2
3 changed files with 31 additions and 6 deletions

View File

@ -25,6 +25,16 @@ class ImportRowModifierForm extends DirectorObjectForm
'required' => true,
));
$this->addElement('text', 'target_property', array(
'label' => $this->translate('Target property'),
'description' => $this->translate(
'You might want to write the modified value to another (new) property.'
. ' This property name can be defined here, the original property would'
. ' remain unmodified. Please leave this blank in case you just want to'
. ' modify the value of a specific property'
),
));
$error = false;
try {
$mods = $this->enumModifiers();

View File

@ -9,6 +9,8 @@ abstract class PropertyModifierHook
{
protected $settings = array();
private $targetProperty;
private $db;
public function getName()
@ -26,9 +28,20 @@ abstract class PropertyModifierHook
return $class;
}
public function setTargetProperty($property)
{
$this->targetProperty = $property;
return $this;
}
public function hasTargetProperty()
{
return $this->targetProperty !== null;
}
public function getTargetProperty()
{
return null;
return $this->targetProperty;
}
public function setDb(Db $db)

View File

@ -13,11 +13,12 @@ class ImportRowModifier extends DbObjectWithSettings
protected $autoincKeyName = 'id';
protected $defaultProperties = array(
'id' => null,
'source_id' => null,
'property_name' => null,
'provider_class' => null,
'priority' => null,
'id' => null,
'source_id' => null,
'property_name' => null,
'provider_class' => null,
'target_property' => null,
'priority' => null,
);
protected $settingsTable = 'import_row_modifier_setting';
@ -31,6 +32,7 @@ class ImportRowModifier extends DbObjectWithSettings
if ($this->hookInstance === null) {
$obj = new $this->provider_class;
$obj->setSettings($this->getSettings());
$obj->setTargetProperty($this->target_property);
$obj->setDb($this->connection);
$this->hookInstance = $obj;
}