3 namespace Drupal\migrate_plus\Plugin\migrate\process;
5 use Drupal\Component\Transliteration\TransliterationInterface;
6 use Drupal\Core\Language\LanguageInterface;
7 use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
8 use Drupal\migrate\ProcessPluginBase;
9 use Drupal\migrate\MigrateExecutableInterface;
10 use Drupal\migrate\Row;
11 use Symfony\Component\DependencyInjection\ContainerInterface;
14 * Transliterates text from Unicode to US-ASCII.
16 * The transliteration process plugin takes the source value and runs it through
17 * the transliteration service. Letters will have language decorations and
25 * plugin: transliteration
29 * If the value of foo in the source is 'áéí!' then the destination value of
32 * @see \Drupal\migrate\Plugin\MigrateProcessInterface
34 * @MigrateProcessPlugin(
35 * id = "transliteration"
38 class Transliteration extends ProcessPluginBase implements ContainerFactoryPluginInterface {
41 * The transliteration service.
43 * @var \Drupal\Component\Transliteration\TransliterationInterface
45 protected $transliteration;
48 * Constructs a Transliteration plugin.
50 * @param array $configuration
51 * The plugin configuration.
52 * @param string $plugin_id
54 * @param mixed $plugin_definition
55 * The plugin definition.
56 * @param \Drupal\Component\Transliteration\TransliterationInterface $transliteration
57 * The transliteration service.
59 public function __construct(array $configuration, $plugin_id, $plugin_definition, TransliterationInterface $transliteration) {
60 parent::__construct($configuration, $plugin_id, $plugin_definition);
61 $this->transliteration = $transliteration;
67 public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
72 $container->get('transliteration')
79 public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
80 return $this->transliteration->transliterate($value, LanguageInterface::LANGCODE_DEFAULT, '_');