public function Node::buildMigrations in Zircon Profile 8
Same name in this branch
- 8 core/modules/node/src/Plugin/migrate/builder/d6/Node.php \Drupal\node\Plugin\migrate\builder\d6\Node::buildMigrations()
- 8 core/modules/node/src/Plugin/migrate/builder/d7/Node.php \Drupal\node\Plugin\migrate\builder\d7\Node::buildMigrations()
Same name and namespace in other branches
- 8.0 core/modules/node/src/Plugin/migrate/builder/d7/Node.php \Drupal\node\Plugin\migrate\builder\d7\Node::buildMigrations()
Builds migration entities based on a template.
Parameters
array $template: The parsed template.
Return value
\Drupal\migrate\Entity\MigrationInterface[] The unsaved migrations generated from the template.
Overrides MigrateBuilderInterface::buildMigrations
File
- core/
modules/ node/ src/ Plugin/ migrate/ builder/ d7/ Node.php, line 21 - Contains \Drupal\node\Plugin\migrate\builder\d7\Node.
Class
- Node
- Plugin annotation @PluginID("d7_node");
Namespace
Drupal\node\Plugin\migrate\builder\d7Code
public function buildMigrations(array $template) {
$migrations = [];
// Read all field instance definitions in the source database.
$fields = array();
foreach ($this
->getSourcePlugin('d7_field_instance', $template['source']) as $field) {
$info = $field
->getSource();
$fields[$info['entity_type']][$info['bundle']][$info['field_name']] = $info;
}
foreach ($this
->getSourcePlugin('d7_node_type', $template['source']) as $node_type) {
$bundle = $node_type
->getSourceProperty('type');
$values = $template;
$values['id'] .= '__' . $bundle;
$values['label'] = $this
->t('@label (@type)', [
'@label' => $values['label'],
'@type' => $node_type
->getSourceProperty('name'),
]);
$values['source']['node_type'] = $bundle;
$migration = Migration::create($values);
if (isset($fields['node'][$bundle])) {
foreach ($fields['node'][$bundle] as $field => $data) {
if ($this->cckPluginManager
->hasDefinition($data['type'])) {
$this
->getCckPlugin($data['type'])
->processCckFieldValues($migration, $field, $data);
}
else {
$migration
->setProcessOfProperty($field, $field);
}
}
}
$migrations[] = $migration;
}
return $migrations;
}