public function ParagraphsStripFieldPrefix::transform

File

paragraphs/src/Plugin/migrate/process/ParagraphsStripFieldPrefix.php, line 26

Class

ParagraphsStripFieldPrefix
Remove 'field_' from the start of a string.

Namespace

Drupal\paragraphs\Plugin\migrate\process

Code

public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
  if (!is_string($value)) {
    throw new MigrateException('The input value must be a string.');
  }
  if (mb_substr($value, 0, FieldCollection::FIELD_COLLECTION_PREFIX_LENGTH) === 'field_') {
    return mb_substr($value, FieldCollection::FIELD_COLLECTION_PREFIX_LENGTH);
  }
  else {
    return $value;
  }
}