protected function Node::getCckData in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/node/src/Plugin/migrate/source/d6/Node.php \Drupal\node\Plugin\migrate\source\d6\Node::getCckData()
Retrieves raw CCK field data for a node.
Parameters
array $field: A field and instance definition from getFieldInfo().
\Drupal\migrate\Row $node: The node.
Return value
array The field values, keyed by delta.
1 call to Node::getCckData()
- Node::getFieldValues in core/
modules/ node/ src/ Plugin/ migrate/ source/ d6/ Node.php - Gets CCK field values for a node.
File
- core/
modules/ node/ src/ Plugin/ migrate/ source/ d6/ Node.php, line 199 - Contains \Drupal\node\Plugin\migrate\source\d6\Node.
Class
- Node
- Drupal 6 node source from database.
Namespace
Drupal\node\Plugin\migrate\source\d6Code
protected function getCckData(array $field, Row $node) {
$field_table = 'content_' . $field['field_name'];
$node_table = 'content_type_' . $node
->getSourceProperty('type');
/** @var \Drupal\Core\Database\Schema $db */
$db = $this
->getDatabase()
->schema();
if ($db
->tableExists($field_table)) {
$query = $this
->select($field_table, 't');
// If the delta column does not exist, add it as an expression to
// normalize the query results.
if ($db
->fieldExists($field_table, 'delta')) {
$query
->addField('t', 'delta');
}
else {
$query
->addExpression(0, 'delta');
}
}
elseif ($db
->tableExists($node_table)) {
$query = $this
->select($node_table, 't');
// Every row should have a delta of 0.
$query
->addExpression(0, 'delta');
}
if (isset($query)) {
$columns = array_keys($field['db_columns']);
// Add every column in the field's schema.
foreach ($columns as $column) {
$query
->addField('t', $field['field_name'] . '_' . $column, $column);
}
return $query
->isNotNull($field['field_name'] . '_' . $columns[0])
->condition('nid', $node
->getSourceProperty('nid'))
->condition('vid', $node
->getSourceProperty('vid'))
->execute()
->fetchAllAssoc('delta');
}
else {
return [];
}
}