You are here

public function FieldInstance::prepareRow in Zircon Profile 8

Same name in this branch
  1. 8 core/modules/field/src/Plugin/migrate/source/d6/FieldInstance.php \Drupal\field\Plugin\migrate\source\d6\FieldInstance::prepareRow()
  2. 8 core/modules/field/src/Plugin/migrate/source/d7/FieldInstance.php \Drupal\field\Plugin\migrate\source\d7\FieldInstance::prepareRow()
Same name and namespace in other branches
  1. 8.0 core/modules/field/src/Plugin/migrate/source/d7/FieldInstance.php \Drupal\field\Plugin\migrate\source\d7\FieldInstance::prepareRow()

Add 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

core/modules/field/src/Plugin/migrate/source/d7/FieldInstance.php, line 66
Contains \Drupal\field\Plugin\migrate\source\d7\FieldInstance.

Class

FieldInstance
Drupal 7 field instances source from database.

Namespace

Drupal\field\Plugin\migrate\source\d7

Code

public function prepareRow(Row $row) {
  $data = unserialize($row
    ->getSourceProperty('data'));
  $row
    ->setSourceProperty('label', $data['label']);
  $row
    ->setSourceProperty('description', $data['description']);
  $row
    ->setSourceProperty('required', $data['required']);
  $default_value = !empty($data['default_value']) ? $data['default_value'] : array();
  if ($data['widget']['type'] == 'email_textfield' && $default_value) {
    $default_value[0]['value'] = $default_value[0]['email'];
    unset($default_value[0]['email']);
  }
  $row
    ->setSourceProperty('default_value', $default_value);

  // Settings.
  $row
    ->setSourceProperty('instance_settings', $data['settings']);
  $row
    ->setSourceProperty('widget_settings', $data['widget']);
  $row
    ->setSourceProperty('display_settings', $data['display']);

  // This is for parity with the d6_field_instance plugin.
  $row
    ->setSourceProperty('widget_type', $data['widget']['type']);
  return parent::prepareRow($row);
}