You are here

public function FieldablePanelsPane::prepareRow in Fieldable Panels Panes (FPP) 1.0.x

Adds additional data to the row.

Parameters

\Drupal\migrate\Row $row: The row object.

Return value

bool FALSE if this row needs to be skipped.

Overrides SourcePluginBase::prepareRow

File

src/Plugin/migrate/source/d7/FieldablePanelsPane.php, line 99

Class

FieldablePanelsPane
Drupal 7 node source from database.

Namespace

Drupal\fieldable_panels_panes\Plugin\migrate\source\d7

Code

public function prepareRow(Row $row) {
  $fpid = $row
    ->getSourceProperty('fpid');
  $vid = $row
    ->getSourceProperty('vid');
  $bundle = $row
    ->getSourceProperty('bundle');

  // If this entity was translated using Entity Translation, we need to get
  // its source language to get the field values in the right language.
  // The  translations will be migrated by the
  // d7_fieldable_panels_pane_entity_translation migration.
  $entity_translatable = $this
    ->isEntityTranslatable('fieldable_panels_pane');
  $source_language = $this
    ->getEntityTranslationSourceLanguage('fieldable_panels_pane', $fpid);
  $language = $entity_translatable && $source_language ? $source_language : $row
    ->getSourceProperty('language');

  // Get Field API field values.
  foreach ($this
    ->getFields('fieldable_panels_pane', $bundle) as $field_name => $field) {

    // Ensure we're using the right language if the entity and the field are
    // translatable.
    $field_language = $entity_translatable && $field['translatable'] ? $language : NULL;
    $row
      ->setSourceProperty($field_name, $this
      ->getFieldValues('fieldable_panels_pane', $field_name, $fpid, $vid, $field_language));
  }

  // If the title was replaced by a real field using the Drupal 7 Title
  // module, use the field value instead of the node title.
  if ($this
    ->moduleExists('title')) {
    $title_field = $row
      ->getSourceProperty('title_field');
    if (isset($title_field[0]['value'])) {
      $row
        ->setSourceProperty('title', $title_field[0]['value']);
    }
  }
  return parent::prepareRow($row);
}