Issue #2827897 by quietone, danflanagan8, mikelutz, smustgrave, mikeryan, osopolar, xurizaemon, benjifisher: Update documentation for handling dots in the static_map plugin

(cherry picked from commit 4da76f6b37)
merge-requests/7427/head
Alex Pott 2024-04-14 11:15:12 +01:00
parent 071c5c2189
commit a1e704d78d
No known key found for this signature in database
GPG Key ID: BDA67E7EE836E5CE
2 changed files with 17 additions and 5 deletions

View File

@ -29,6 +29,13 @@ use Drupal\migrate\MigrateSkipRowException;
* - 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
@ -134,11 +141,6 @@ use Drupal\migrate\MigrateSkipRowException;
* 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
*/

View File

@ -113,4 +113,14 @@ class StaticMapTest extends MigrateProcessTestCase {
$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);
}
}