3 namespace Drupal\media_entity;
5 use Drupal\Core\Field\FieldItemInterface;
8 * A trait to assist with handling external embed codes.
10 trait EmbedCodeValueTrait {
13 * Extracts the raw embed code from input which may or may not be wrapped.
16 * The input value. Can be a normal string or a value wrapped by the
22 protected function getEmbedCode($value) {
23 if (is_string($value)) {
26 elseif ($value instanceof FieldItemInterface) {
27 $class = get_class($value);
28 $property = $class::mainPropertyName();
30 return $value->$property;