Remove 'field_' from the start of a string.
@MigrateProcessPlugin(
id = "paragraphs_strip_field_prefix"
)
Expanded class hierarchy of ParagraphsStripFieldPrefix
\Drupal\migrate\Plugin\MigrateProcessInterface
class ParagraphsStripFieldPrefix extends ProcessPluginBase {
/**
* {@inheritdoc}
*/
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;
}
}
}
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ParagraphsStripFieldPrefix:: |
public | function |