From 592d05415fcc9bd77afa530313a7f883e15f084c Mon Sep 17 00:00:00 2001 From: Kristiaan Van den Eynde Date: Wed, 10 Apr 2019 12:13:56 +0200 Subject: [PATCH] interdiff --- src/Plugin/migrate/process/CallbackArray.php | 26 +++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/Plugin/migrate/process/CallbackArray.php b/src/Plugin/migrate/process/CallbackArray.php index e4f89c2..73acc24 100644 --- a/src/Plugin/migrate/process/CallbackArray.php +++ b/src/Plugin/migrate/process/CallbackArray.php @@ -82,7 +82,31 @@ class CallbackArray extends Callback { * {@inheritdoc} */ public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) { - $parameters = array_splice($this->configuration['parameters'], $this->configuration['source_index'], 0, [$value]); + $parameters = []; + + foreach ($this->configuration['parameters'] as $parameter) { + $is_source = TRUE; + + if ($parameter[0] == '@') { + $parameter = preg_replace_callback('/^(@?)((?:@@)*)([^@]|$)/', function ($matches) use (&$is_source) { + // If there are an odd number of @ in the beginning, it's a + // destination. + $is_source = empty($matches[1]); + // Remove the possible escaping and do not lose the terminating + // non-@ either. + return str_replace('@@', '@', $matches[2]) . $matches[3]; + }, $parameter); + } + + if ($is_source) { + $parameters[] = $row->getSourceProperty($parameter); + } + else { + $parameters[] = $row->getDestinationProperty($parameter); + } + } + + array_splice($parameters, $this->configuration['source_index'], 0, [$value]); return call_user_func_array($this->configuration['callable'], $parameters); } -- 2.17.1