diff -u b/core/modules/migrate/src/Row.php b/core/modules/migrate/src/Row.php --- b/core/modules/migrate/src/Row.php +++ b/core/modules/migrate/src/Row.php @@ -279,7 +279,19 @@ * The destination value. */ public function getDestinationProperty($property) { - return NestedArray::getValue($this->destination, explode(static::PROPERTY_SEPARATOR, $property)); + $parents = explode(static::PROPERTY_SEPARATOR, $property); + $value = NestedArray::getValue($this->destination, $parents, $key_exists); + if (!$key_exists) { + $value = []; + $child = array_pop($parents); + $parent_value = NestedArray::getValue($this->destination, $parents, $key_exists); + foreach ($parent_value as $key => $subvalue) { + if (is_array($subvalue) && isset($subvalue[$child])) { + $value[$key] = $subvalue[$child]; + } + } + } + return $value; } /** only in patch2: unchanged: --- a/core/modules/migrate/tests/src/Unit/RowTest.php +++ b/core/modules/migrate/tests/src/Unit/RowTest.php @@ -260,15 +260,38 @@ public function testMultipleDestination() { $row->setDestinationProperty('image/alt', 'alt text'); $row->setDestinationProperty('image/fid', 3); + $row->setDestinationProperty('body/value', [ + 'Body 1', + 'Body 2', + ]); + $row->setDestinationProperty('body/format', [ + 'basic_html', + 'full_html', + ]); + $row->setDestinationProperty('body/summary', [ + 'Summary 1', + 'Summary 2', + ]); + $this->assertTrue($row->hasDestinationProperty('image')); $this->assertFalse($row->hasDestinationProperty('alt')); $this->assertFalse($row->hasDestinationProperty('fid')); + $this->assertTrue($row->hasDestinationProperty('body')); + $this->assertFalse($row->hasDestinationProperty('value')); + $this->assertFalse($row->hasDestinationProperty('format')); + $this->assertFalse($row->hasDestinationProperty('summary')); + $destination = $row->getDestination(); $this->assertEquals('alt text', $destination['image']['alt']); $this->assertEquals(3, $destination['image']['fid']); $this->assertEquals('alt text', $row->getDestinationProperty('image/alt')); $this->assertEquals(3, $row->getDestinationProperty('image/fid')); + + $this->assertEquals('Body 1', $destination['body'][0]['value']); + $this->assertEquals('full_html', $destination['body'][1]['format']); + $this->assertEquals(['Summary 1', 'Summary 2'], $row->getDestinationProperty('body/summary')); + $this->assertEquals(['basic_html', 'full_html'], $row->getDestinationProperty('body/format')); } }