public function MerciBucket::prepareRow in MERCI (Manage Equipment Reservations, Checkout and Inventory) 8.2
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 NodeType::prepareRow
File
- modules/
merci_migration/ src/ Plugin/ migrate/ source/ d7/ MerciBucket.php, line 50
Class
- MerciBucket
- Drupal 7 node source from database.
Namespace
Drupal\merci_migration\Plugin\migrate\source\d7Code
public function prepareRow(Row $row) {
// Get Field API field values.
$type = $row
->getSourceProperty('type');
$query = $this
->select('variable', 'v')
->fields('v')
->condition('name', 'merci_grouping_' . $type);
$result = $query
->execute()
->fetchAll();
if (!empty($result)) {
$tid = unserialize($result[0]['value']);
if ($tid) {
$row
->setSourceProperty('resource_tree', $tid);
}
}
// Select node in its last revision.
$query = $this
->select('node_revision', 'nr')
->fields('n', [
'nid',
'type',
'language',
'status',
'created',
'changed',
'comment',
'promote',
'sticky',
'tnid',
'translate',
])
->fields('nr', [
'vid',
'title',
'log',
'timestamp',
]);
$query
->addField('n', 'uid', 'node_uid');
$query
->addField('nr', 'uid', 'revision_uid');
$query
->innerJoin('node', 'n', static::JOIN);
$query
->leftJoin('merci_bucket_node', 'mbn', 'n.nid = mbn.nid');
$query
->condition('mbn.merci_sub_type', '1');
$query
->condition('type', $type);
$result = $query
->execute()
->fetchAll();
$row
->setSourceProperty('bucket_items', $result);
return parent::prepareRow($row);
}