protected function EntityShareEmbeddedEntitiesEnhancer::doTransform in Entity Share 8.3
File
- src/
Plugin/ jsonapi/ FieldEnhancer/ EntityShareEmbeddedEntitiesEnhancer.php, line 89
Class
- EntityShareEmbeddedEntitiesEnhancer
- Alter rich text exposed data to provide import URL for embedded entities.
Namespace
Drupal\entity_share\Plugin\jsonapi\FieldEnhancerCode
protected function doTransform($value, Context $context) {
// Formatted text detection.
if (!isset($value['format']) || !isset($value['value'])) {
return $value;
}
// Remove data-entity-jsonapi-url HTML attribute.
$value['value'] = preg_replace('# data-entity-jsonapi-url="(.*)"#U', '', $value['value']);
// For img tag, update the src attribute.
$value['value'] = preg_replace_callback('#(<img.*data-entity-type="(.*)".*data-entity-uuid="(.*)".*)(/?)>#U', [
self::class,
'updateImgSrc',
], $value['value']);
return $value;
}