protected function FieldInstance::initializeIterator in Drupal 9
Same name and namespace in other branches
- 8 core/modules/field/src/Plugin/migrate/source/d7/FieldInstance.php \Drupal\field\Plugin\migrate\source\d7\FieldInstance::initializeIterator()
Initializes the iterator with the source data.
Return value
\Iterator Returns an iterable object of data for this source.
Overrides SqlBase::initializeIterator
2 calls to FieldInstance::initializeIterator()
- FieldInstancePerViewMode::initializeIterator in core/
modules/ field/ src/ Plugin/ migrate/ source/ d7/ FieldInstancePerViewMode.php - Initializes the iterator with the source data.
- ViewMode::initializeIterator in core/
modules/ field/ src/ Plugin/ migrate/ source/ d7/ ViewMode.php - Initializes the iterator with the source data.
2 methods override FieldInstance::initializeIterator()
- FieldInstancePerViewMode::initializeIterator in core/
modules/ field/ src/ Plugin/ migrate/ source/ d7/ FieldInstancePerViewMode.php - Initializes the iterator with the source data.
- ViewMode::initializeIterator in core/
modules/ field/ src/ Plugin/ migrate/ source/ d7/ ViewMode.php - Initializes the iterator with the source data.
File
- core/
modules/ field/ src/ Plugin/ migrate/ source/ d7/ FieldInstance.php, line 94
Class
- FieldInstance
- Drupal 7 field instances source from database.
Namespace
Drupal\field\Plugin\migrate\source\d7Code
protected function initializeIterator() {
$results = $this
->prepareQuery()
->execute()
->fetchAll();
// Group all instances by their base field.
$instances = [];
foreach ($results as $result) {
$instances[$result['field_id']][] = $result;
}
// Add the array of all instances using the same base field to each row.
$rows = [];
foreach ($results as $result) {
$result['instances'] = $instances[$result['field_id']];
$rows[] = $result;
}
return new \ArrayIterator($rows);
}