public function ProfileField::prepareRow in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/user/src/Plugin/migrate/source/ProfileField.php \Drupal\user\Plugin\migrate\source\ProfileField::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/ user/ src/ Plugin/ migrate/ source/ ProfileField.php, line 57 - Contains \Drupal\user\Plugin\migrate\source\ProfileField.
Class
- ProfileField
- Profile field source from database.
Namespace
Drupal\user\Plugin\migrate\sourceCode
public function prepareRow(Row $row) {
if ($row
->getSourceProperty('type') == 'selection') {
// Get the current options.
$current_options = preg_split("/[\r\n]+/", $row
->getSourceProperty('options'));
// Select the list values from the profile_values table to ensure we get
// them all since they can get out of sync with profile_fields.
$options = $this
->select($this->valueTable, 'pv')
->distinct()
->fields('pv', [
'value',
])
->condition('fid', $row
->getSourceProperty('fid'))
->execute()
->fetchCol();
$options = array_merge($current_options, $options);
// array_combine() takes care of any duplicates options.
$row
->setSourceProperty('options', array_combine($options, $options));
}
if ($row
->getSourceProperty('type') == 'checkbox') {
// D6 profile checkboxes values are always 0 or 1 (with no labels), so we
// need to create two label-less options that will get 0 and 1 for their
// keys.
$row
->setSourceProperty('options', array(
NULL,
NULL,
));
}
return parent::prepareRow($row);
}