Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / chi-teck / drupal-code-generator / templates / d8 / plugin / migrate / process.twig
diff --git a/vendor/chi-teck/drupal-code-generator/templates/d8/plugin/migrate/process.twig b/vendor/chi-teck/drupal-code-generator/templates/d8/plugin/migrate/process.twig
new file mode 100644 (file)
index 0000000..4b01043
--- /dev/null
@@ -0,0 +1,79 @@
+<?php
+
+namespace Drupal\{{ machine_name }}\Plugin\migrate\process;
+
+use Drupal\Component\Transliteration\TransliterationInterface;
+use Drupal\Core\Language\LanguageInterface;
+use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
+use Drupal\migrate\MigrateExecutableInterface;
+use Drupal\migrate\ProcessPluginBase;
+use Drupal\migrate\Row;
+use Symfony\Component\DependencyInjection\ContainerInterface;
+
+/**
+ * Provides {{ plugin_id|article }} plugin.
+ *
+ * Usage:
+ *
+ * @code
+ * process:
+ *   bar:
+ *     plugin: {{ plugin_id }}
+ *     source: foo
+ * @endcode
+ *
+ * @MigrateProcessPlugin(
+ *   id = "{{ plugin_id }}"
+ * )
+ *
+ * @DCG
+ * ContainerFactoryPluginInterface is optional here. If you have no need for
+ * external services just remove it and all other stuff except transform()
+ * method.
+ */
+class {{ class }} extends ProcessPluginBase implements ContainerFactoryPluginInterface {
+
+  /**
+   * The transliteration service.
+   *
+   * @var \Drupal\Component\Transliteration\TransliterationInterface
+   */
+  protected $transliteration;
+
+  /**
+   * Constructs {{ class|article }} plugin.
+   *
+   * @param array $configuration
+   *   The plugin configuration.
+   * @param string $plugin_id
+   *   The plugin ID.
+   * @param mixed $plugin_definition
+   *   The plugin definition.
+   * @param \Drupal\Component\Transliteration\TransliterationInterface $transliteration
+   *   The transliteration service.
+   */
+  public function __construct(array $configuration, $plugin_id, $plugin_definition, TransliterationInterface $transliteration) {
+    parent::__construct($configuration, $plugin_id, $plugin_definition);
+    $this->transliteration = $transliteration;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
+    return new static(
+      $configuration,
+      $plugin_id,
+      $plugin_definition,
+      $container->get('transliteration')
+    );
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
+    return $this->transliteration->transliterate($value, LanguageInterface::LANGCODE_DEFAULT);
+  }
+
+}