function MachineName::transform

Same name in other branches
  1. 9 core/modules/migrate/src/Plugin/migrate/process/MachineName.php \Drupal\migrate\Plugin\migrate\process\MachineName::transform()
  2. 10 core/modules/migrate/src/Plugin/migrate/process/MachineName.php \Drupal\migrate\Plugin\migrate\process\MachineName::transform()
  3. 11.x core/modules/migrate/src/Plugin/migrate/process/MachineName.php \Drupal\migrate\Plugin\migrate\process\MachineName::transform()

Overrides ProcessPluginBase::transform

File

core/modules/migrate/src/Plugin/migrate/process/MachineName.php, line 82

Class

MachineName
Creates a machine name.

Namespace

Drupal\migrate\Plugin\migrate\process

Code

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);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.