Loading core/modules/migrate/src/Plugin/migrate/process/StaticMap.php +7 −5 Original line number Diff line number Diff line Loading @@ -29,6 +29,13 @@ * - default_value: (optional) The value to return if the source is not found in * the map array. * * While this plugin supports map key values which contain a dot (.), Drupal * configuration export does not export keys which contain a dot. Be careful * when using this feature with migrations that are stored as configuration * entities. These entities cannot contain keys with a dot. In this case, * additional manipulation with either custom or contrib process plugins is * needed. * * Examples: * * If the value of the source property 'foo' is 'from' then the value of the Loading Loading @@ -134,11 +141,6 @@ * 1: bar * @endcode * * Mapping from a string which contains a period is not supported. A custom * process plugin can be written to handle this kind of a transformation. * Another option which may be feasible in certain use cases is to first pass * the value through the machine_name process plugin. * * @see https://www.drupal.org/project/drupal/issues/2827897 * @see \Drupal\migrate\Plugin\MigrateProcessInterface */ Loading core/modules/migrate/tests/src/Unit/process/StaticMapTest.php +10 −0 Original line number Diff line number Diff line Loading @@ -113,4 +113,14 @@ public function testWithNullSource() { $this->assertSame('mapped NULL', $value); } /** * Tests when there is a dot in a map key. */ public function testMapDotInKey(): void { $configuration['map']['foo.bar'] = 'baz'; $this->plugin = new StaticMap($configuration, 'map', []); $value = $this->plugin->transform('foo.bar', $this->migrateExecutable, $this->row, 'destination_property'); $this->assertSame('baz', $value); } } Loading
core/modules/migrate/src/Plugin/migrate/process/StaticMap.php +7 −5 Original line number Diff line number Diff line Loading @@ -29,6 +29,13 @@ * - default_value: (optional) The value to return if the source is not found in * the map array. * * While this plugin supports map key values which contain a dot (.), Drupal * configuration export does not export keys which contain a dot. Be careful * when using this feature with migrations that are stored as configuration * entities. These entities cannot contain keys with a dot. In this case, * additional manipulation with either custom or contrib process plugins is * needed. * * Examples: * * If the value of the source property 'foo' is 'from' then the value of the Loading Loading @@ -134,11 +141,6 @@ * 1: bar * @endcode * * Mapping from a string which contains a period is not supported. A custom * process plugin can be written to handle this kind of a transformation. * Another option which may be feasible in certain use cases is to first pass * the value through the machine_name process plugin. * * @see https://www.drupal.org/project/drupal/issues/2827897 * @see \Drupal\migrate\Plugin\MigrateProcessInterface */ Loading
core/modules/migrate/tests/src/Unit/process/StaticMapTest.php +10 −0 Original line number Diff line number Diff line Loading @@ -113,4 +113,14 @@ public function testWithNullSource() { $this->assertSame('mapped NULL', $value); } /** * Tests when there is a dot in a map key. */ public function testMapDotInKey(): void { $configuration['map']['foo.bar'] = 'baz'; $this->plugin = new StaticMap($configuration, 'map', []); $value = $this->plugin->transform('foo.bar', $this->migrateExecutable, $this->row, 'destination_property'); $this->assertSame('baz', $value); } }