protected function PinterestEmbedFormatter::getEmbedCode in Media entity Pinterest 8.2
Same name and namespace in other branches
- 8 src/Plugin/Field/FieldFormatter/PinterestEmbedFormatter.php \Drupal\media_entity_pinterest\Plugin\Field\FieldFormatter\PinterestEmbedFormatter::getEmbedCode()
Extracts the embed code from a field item.
Parameters
\Drupal\Core\Field\FieldItemInterface $item: The field item.
Return value
string|null The embed code, or NULL if the field type is not supported.
1 call to PinterestEmbedFormatter::getEmbedCode()
- PinterestEmbedFormatter::viewElements in src/
Plugin/ Field/ FieldFormatter/ PinterestEmbedFormatter.php - Builds a renderable array for a field value.
File
- src/
Plugin/ Field/ FieldFormatter/ PinterestEmbedFormatter.php, line 144
Class
- PinterestEmbedFormatter
- Plugin implementation of the 'pinterest_embed' formatter.
Namespace
Drupal\media_entity_pinterest\Plugin\Field\FieldFormatterCode
protected function getEmbedCode(FieldItemInterface $item) {
switch ($item
->getFieldDefinition()
->getType()) {
case 'link':
return $item->uri;
case 'string':
case 'string_long':
return $item->value;
default:
break;
}
}