You are here

protected function GatherContentMigrateSource::getFieldValue in GatherContent 8.5

Get field's value.

Parameters

mixed $field: Field object/objects.

Return value

array Returns value.

1 call to GatherContentMigrateSource::getFieldValue()
GatherContentMigrateSource::prepareRow in src/Plugin/migrate/source/GatherContentMigrateSource.php
Adds additional data to the row.

File

src/Plugin/migrate/source/GatherContentMigrateSource.php, line 336

Class

GatherContentMigrateSource
A source class for Gathercontent API.

Namespace

Drupal\gathercontent\Plugin\migrate\source

Code

protected function getFieldValue($field) {
  if (!is_array($field)) {
    return $field
      ->getValue();
  }
  $value = [];
  foreach ($field as $item) {
    if ($item instanceof ElementSimpleChoice) {
      $value[] = [
        'gc_id' => $item->id,
      ];
    }
    if ($item instanceof ElementSimpleFile) {
      $value[] = $item;
    }
  }
  return $value;
}