diff --git a/application/forms/ImportRowModifierForm.php b/application/forms/ImportRowModifierForm.php index 4b640c04..3e280ee5 100644 --- a/application/forms/ImportRowModifierForm.php +++ b/application/forms/ImportRowModifierForm.php @@ -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(); diff --git a/library/Director/Hook/PropertyModifierHook.php b/library/Director/Hook/PropertyModifierHook.php index c5d2751f..8ad195c3 100644 --- a/library/Director/Hook/PropertyModifierHook.php +++ b/library/Director/Hook/PropertyModifierHook.php @@ -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) diff --git a/library/Director/Objects/ImportRowModifier.php b/library/Director/Objects/ImportRowModifier.php index 240074ef..5ee94c0e 100644 --- a/library/Director/Objects/ImportRowModifier.php +++ b/library/Director/Objects/ImportRowModifier.php @@ -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; }