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/d6/Node.php \Drupal\node\Plugin\migrate\builder\d6\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/ d6/ Node.php, line 22 - Contains \Drupal\node\Plugin\migrate\builder\d6\Node.
Class
- Node
- Plugin annotation @PluginID("d6_node");
Namespace
Drupal\node\Plugin\migrate\builder\d6Code
public function buildMigrations(array $template) {
$migrations = [];
// Read all CCK field instance definitions in the source database.
$fields = array();
$source_plugin = $this
->getSourcePlugin('d6_field_instance', $template['source']);
try {
$source_plugin
->checkRequirements();
foreach ($source_plugin as $field) {
$info = $field
->getSource();
$fields[$info['type_name']][$info['field_name']] = $info;
}
} catch (RequirementsException $e) {
// Don't do anything; $fields will be empty.
}
foreach ($this
->getSourcePlugin('d6_node_type', $template['source']) as $row) {
$node_type = $row
->getSourceProperty('type');
$values = $template;
$values['id'] = $template['id'] . '__' . $node_type;
$label = $template['label'];
$values['label'] = $this
->t("@label (@type)", [
'@label' => $label,
'@type' => $node_type,
]);
$values['source']['node_type'] = $node_type;
// If this migration is based on the d6_node_revision template, it should
// explicitly depend on the corresponding d6_node variant.
if ($template['id'] == 'd6_node_revision') {
$values['migration_dependencies']['required'][] = 'd6_node__' . $node_type;
}
$migration = Migration::create($values);
if (isset($fields[$node_type])) {
foreach ($fields[$node_type] as $field => $info) {
if ($this->cckPluginManager
->hasDefinition($info['type'])) {
$this
->getCckPlugin($info['type'])
->processCckFieldValues($migration, $field, $info);
}
else {
$migration
->setProcessOfProperty($field, $field);
}
}
}
$migrations[] = $migration;
}
return $migrations;
}