You are here

protected function YouTubeItem::prepareValue in YouTube Field 8

Prepares a single value.

Parameters

int $delta: The field delta.

array $values: The values.

Overrides FieldTargetBase::prepareValue

File

src/Feeds/Target/YouTubeItem.php, line 33

Class

YouTubeItem
Defines a YouTube field mapper.

Namespace

Drupal\youtube\Feeds\Target

Code

protected function prepareValue($delta, array &$values) {

  // Both the Video URL (input) and Video ID are required for the field value
  // to work. If the feed only provided one, generate the other.
  if (!empty($values['input']) && empty($values['video_id'])) {
    $values['video_id'] = youtube_get_video_id($values['input']);
  }
  elseif (empty($values['input']) && !empty($values['video_id'])) {
    $values['input'] = 'https://www.youtube.com/watch?v=' . $values['video_id'];
  }
}