public function Subscriber::prepareRow in Simplenews 8
Same name and namespace in other branches
- 8.2 src/Plugin/migrate/source/d7/Subscriber.php \Drupal\simplenews\Plugin\migrate\source\d7\Subscriber::prepareRow()
- 3.x src/Plugin/migrate/source/d7/Subscriber.php \Drupal\simplenews\Plugin\migrate\source\d7\Subscriber::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
- src/
Plugin/ migrate/ source/ d7/ Subscriber.php, line 52
Class
- Subscriber
- Migration source for Subscriber entries in D7.
Namespace
Drupal\simplenews\Plugin\migrate\source\d7Code
public function prepareRow(Row $row) {
$result = parent::prepareRow($row);
$version = $this
->getModuleSchemaVersion('simplenews');
$newsletter_id_field = 'newsletter_id';
if ($version >= 7000 & $version < 7200) {
$newsletter_id_field = 'tid';
}
// Add associated data from the subscriptions table.
$q = $this
->select('simplenews_subscription', 'sub');
$q
->addField('sub', $newsletter_id_field, 'newsletter_id');
$q
->fields('sub', [
'status',
'timestamp',
'source',
]);
$q
->condition('sub.snid', $row
->getSourceProperty('snid'));
$subscriptions = $q
->execute()
->fetchAllAssoc('newsletter_id');
$row
->setSourceProperty('subscriptions', $subscriptions);
return $result;
}