Pull merge.
[yaffs-website] / web / core / modules / migrate / src / Plugin / migrate / destination / Entity.php
index 1b2c2e7a5b583169de6890a867023686ea0c1255..0cebbd07c82432446afbd02e507e019b498828fc 100644 (file)
@@ -11,7 +11,48 @@ use Drupal\migrate\Row;
 use Symfony\Component\DependencyInjection\ContainerInterface;
 
 /**
- * Provides entity destination plugin.
+ * Provides a generic destination to import entities.
+ *
+ * Available configuration keys:
+ * - translations: (optional) Boolean, if TRUE, the destination will be
+ *   associated with the langcode provided by the source plugin. Defaults to
+ *   FALSE.
+ *
+ * Examples:
+ *
+ * @code
+ * source:
+ *   plugin: d7_node
+ * process:
+ *   nid: tnid
+ *   vid: vid
+ *   langcode: language
+ *   title: title
+ *   ...
+ *   revision_timestamp: timestamp
+ * destination:
+ *   plugin: entity:node
+ * @endcode
+ *
+ * This will save the processed, migrated row as a node.
+ *
+ * @code
+ * source:
+ *   plugin: d7_node
+ * process:
+ *   nid: tnid
+ *   vid: vid
+ *   langcode: language
+ *   title: title
+ *   ...
+ *   revision_timestamp: timestamp
+ * destination:
+ *   plugin: entity:node
+ *   translations: true
+ * @endcode
+ *
+ * This will save the processed, migrated row as a node with the relevant
+ * langcode because the translations configuration is set to "true".
  *
  * @MigrateDestination(
  *   id = "entity",
@@ -45,14 +86,18 @@ abstract class Entity extends DestinationBase implements ContainerFactoryPluginI
    *   The plugin_id for the plugin instance.
    * @param mixed $plugin_definition
    *   The plugin implementation definition.
-   * @param MigrationInterface $migration
+   * @param \Drupal\migrate\Plugin\MigrationInterface $migration
    *   The migration.
-   * @param EntityStorageInterface $storage
+   * @param \Drupal\Core\Entity\EntityStorageInterface $storage
    *   The storage for this entity type.
    * @param array $bundles
    *   The list of bundles this entity type has.
    */
   public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityStorageInterface $storage, array $bundles) {
+    $plugin_definition += [
+      'label' => $storage->getEntityType()->getPluralLabel(),
+    ];
+
     parent::__construct($configuration, $plugin_id, $plugin_definition, $migration);
     $this->storage = $storage;
     $this->bundles = $bundles;