You are here

public function FieldGroup::prepareRow in Field Group 8

Same name in this branch
  1. 8 contrib/field_group_migrate/src/Plugin/migrate/source/d6/FieldGroup.php \Drupal\field_group_migrate\Plugin\migrate\source\d6\FieldGroup::prepareRow()
  2. 8 contrib/field_group_migrate/src/Plugin/migrate/source/d7/FieldGroup.php \Drupal\field_group_migrate\Plugin\migrate\source\d7\FieldGroup::prepareRow()
Same name and namespace in other branches
  1. 8.3 contrib/field_group_migrate/src/Plugin/migrate/source/d7/FieldGroup.php \Drupal\field_group_migrate\Plugin\migrate\source\d7\FieldGroup::prepareRow()

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

contrib/field_group_migrate/src/Plugin/migrate/source/d7/FieldGroup.php, line 32
Contains \Drupal\field_group_migrate\Plugin\migrate\source\d7\FieldGroup.

Class

FieldGroup
Drupal 7 field_group source.

Namespace

Drupal\field_group_migrate\Plugin\migrate\source\d7

Code

public function prepareRow(Row $row) {
  $data = unserialize($row
    ->getSourceProperty('data'));
  $format_settings = $data['format_settings'] + $data['format_settings']['instance_settings'];
  unset($format_settings['instance_settings']);
  $settings = array(
    'children' => $data['children'],
    'parent_name' => $row
      ->getSourceProperty('parent_name'),
    'weight' => $data['weight'],
    'label' => $data['label'],
    'format_settings' => $format_settings,
    'format_type' => $data['format_type'],
  );
  switch ($data['format_type']) {
    case 'div':
      $settings['format_type'] = 'html_element';
      $settings['format_settings']['element'] = 'div';
      break;
    case 'tabs':
      $settings['format_type'] = 'tabs';
      $settings['format_settings']['direction'] = 'vertical';
      break;
    case 'htabs':
      $settings['format_type'] = 'tabs';
      $settings['format_settings']['direction'] = 'horizontal';
      break;
    case 'htab':
      $settings['format_type'] = 'tab';
      break;
    case 'multipage-group':

      // @todo Check if there is a better way to deal with this format type.
      $settings['format_type'] = 'tabs';
      break;
    case 'multipage':

      // @todo Check if there is a better way to deal with this format type.
      $settings['format_type'] = 'tab';
      break;
  }
  $row
    ->setSourceProperty('settings', $settings);
  return parent::prepareRow($row);
}