Verified Commit a1e704d7 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2827897 by quietone, danflanagan8, mikelutz, smustgrave, mikeryan,...

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 4da76f6b)
parent 071c5c21
Loading
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -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
@@ -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
 */
+10 −0
Original line number Diff line number Diff line
@@ -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);
  }

}