function FieldInstancePerViewMode::initializeIterator

Same name in this branch
  1. 11.x core/modules/field/src/Plugin/migrate/source/d7/FieldInstancePerViewMode.php \Drupal\field\Plugin\migrate\source\d7\FieldInstancePerViewMode::initializeIterator()
Same name in other branches
  1. 9 core/modules/field/src/Plugin/migrate/source/d6/FieldInstancePerViewMode.php \Drupal\field\Plugin\migrate\source\d6\FieldInstancePerViewMode::initializeIterator()
  2. 9 core/modules/field/src/Plugin/migrate/source/d7/FieldInstancePerViewMode.php \Drupal\field\Plugin\migrate\source\d7\FieldInstancePerViewMode::initializeIterator()
  3. 8.9.x core/modules/field/src/Plugin/migrate/source/d6/FieldInstancePerViewMode.php \Drupal\field\Plugin\migrate\source\d6\FieldInstancePerViewMode::initializeIterator()
  4. 8.9.x core/modules/field/src/Plugin/migrate/source/d7/FieldInstancePerViewMode.php \Drupal\field\Plugin\migrate\source\d7\FieldInstancePerViewMode::initializeIterator()
  5. 10 core/modules/field/src/Plugin/migrate/source/d6/FieldInstancePerViewMode.php \Drupal\field\Plugin\migrate\source\d6\FieldInstancePerViewMode::initializeIterator()
  6. 10 core/modules/field/src/Plugin/migrate/source/d7/FieldInstancePerViewMode.php \Drupal\field\Plugin\migrate\source\d7\FieldInstancePerViewMode::initializeIterator()

Overrides SqlBase::initializeIterator

File

core/modules/field/src/Plugin/migrate/source/d6/FieldInstancePerViewMode.php, line 27

Class

FieldInstancePerViewMode
Drupal 6 field instance per view mode source from database.

Namespace

Drupal\field\Plugin\migrate\source\d6

Code

protected function initializeIterator() {
    $rows = [];
    $result = $this->prepareQuery()
        ->execute();
    while ($field_row = $result->fetchAssoc()) {
        // These are added to every view mode row.
        $field_row['display_settings'] = unserialize($field_row['display_settings']);
        $field_row['widget_settings'] = unserialize($field_row['widget_settings']);
        $bundle = $field_row['type_name'];
        $field_name = $field_row['field_name'];
        foreach ($this->getViewModes() as $view_mode) {
            // Append to the return value if the row has display settings for this
            // view mode and the view mode is neither hidden nor excluded.
            // @see \Drupal\node\Plugin\migrate\source\d6\ViewMode::initializeIterator()
            if (isset($field_row['display_settings'][$view_mode]) && $field_row['display_settings'][$view_mode]['format'] != 'hidden' && empty($field_row['display_settings'][$view_mode]['exclude'])) {
                $index = $view_mode . "." . $bundle . "." . $field_name;
                $rows[$index]['entity_type'] = 'node';
                $rows[$index]['view_mode'] = $view_mode;
                $rows[$index]['type_name'] = $bundle;
                $rows[$index]['field_name'] = $field_name;
                $rows[$index]['type'] = $field_row['type'];
                $rows[$index]['module'] = $field_row['module'];
                $rows[$index]['weight'] = $field_row['weight'];
                $rows[$index]['label'] = $field_row['display_settings']['label']['format'];
                $rows[$index]['display_settings'] = $field_row['display_settings'][$view_mode];
                $rows[$index]['widget_settings'] = $field_row['widget_settings'];
            }
        }
    }
    return new \ArrayIterator($rows);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.