You are here

protected function EmbedCodeValueTrait::getEmbedCode in Media entity 8

Extracts the raw embed code from input which may or may not be wrapped.

Parameters

mixed $value: The input value. Can be a normal string or a value wrapped by the Typed Data API.

Return value

string|null The raw embed code.

File

src/EmbedCodeValueTrait.php, line 22

Class

EmbedCodeValueTrait
A trait to assist with handling external embed codes.

Namespace

Drupal\media_entity

Code

protected function getEmbedCode($value) {
  if (is_string($value)) {
    return $value;
  }
  elseif ($value instanceof FieldItemInterface) {
    $class = get_class($value);
    $property = $class::mainPropertyName();
    if ($property) {
      return $value->{$property};
    }
  }
}