X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fmigrate%2Fsrc%2FPlugin%2Fmigrate%2Fprocess%2FMachineName.php;fp=web%2Fcore%2Fmodules%2Fmigrate%2Fsrc%2FPlugin%2Fmigrate%2Fprocess%2FMachineName.php;h=5a4b4d50696bc9cf7d95dc10aea1ab0b7bf12c96;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hp=0000000000000000000000000000000000000000;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad;p=yaffs-website diff --git a/web/core/modules/migrate/src/Plugin/migrate/process/MachineName.php b/web/core/modules/migrate/src/Plugin/migrate/process/MachineName.php new file mode 100644 index 000000000..5a4b4d506 --- /dev/null +++ b/web/core/modules/migrate/src/Plugin/migrate/process/MachineName.php @@ -0,0 +1,89 @@ +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) { + $new_value = $this->transliteration->transliterate($value, LanguageInterface::LANGCODE_DEFAULT, '_'); + $new_value = strtolower($new_value); + $new_value = preg_replace('/[^a-z0-9_]+/', '_', $new_value); + return preg_replace('/_+/', '_', $new_value); + } + +}