Commit bbfecc8b authored by Aleksey.Alekseev's avatar Aleksey.Alekseev
Browse files

switch for node import

parent ddcb0ede
......@@ -26,15 +26,15 @@ class DrushContentImport extends DrushCommands {
* @command synhelper:content
* @aliases scont
* @options arr An option that takes multiple values.
* @usage synhelper:scont $directory
* @usage synhelper:scont /var/www/console/src/Template/solution/content/
* Import сontacts from
* $directory/contacts.
* /var/www/console/src/Template/solution/content/contacts.
* Import nodes from
* $directory/nodes.
* /var/www/console/src/Template/solution/content/nodes.
* Import taxonomy from
* $directory/taxonomy.
* /var/www/console/src/Template/solution/content/taxonomy.
* Resets SynLandyng config from
* $directory/synlanding.
* /var/www/console/src/Template/solution/content/synlanding.
*/
public function import($directory) {
$this->output()->writeln("Import content from: $directory");
......@@ -176,83 +176,102 @@ class DrushContentImport extends DrushCommands {
*/
private function importNode($data) {
$storage = \Drupal::entityTypeManager()->getStorage('node');
if ($data['type'] == 'project') {
$n = [
'uid' => 1,
'type' => $data['type'],
'title' => $data['title'],
'status' => $data['status'],
'path' => $data['path'],
'created' => $data['created'],
'changed' => $data['changed'],
'promote' => $data['promote'],
'sticky' => $data['sticky'],
'field_short' => $data['field_short'],
'field_size' => $data['field_size'],
'field_material' => $data['field_material'],
'field_area' => $data['field_area'],
'body' => $data['body'],
'field_count_floors' => $data['field_count_floors'],
'field_count_rooms' => $data['field_count_rooms'],
'field_price' => $data['field_price'],
'field_object_type' => $this->importTaxonomyField($data['field_object_type']),
'field_image' => $this->importImages($data['field_image']),
'field_attach' => $this->importAttach($data['field_attach']),
'field_gallery' => $this->importImages($data['field_gallery']),
];
}
elseif ($data['type'] == 'portfolio') {
$n = [
'uid' => 1,
'type' => $data['type'],
'title' => $data['title'],
'status' => $data['status'],
'path' => $data['path'],
'created' => $data['created'],
'changed' => $data['changed'],
'promote' => $data['promote'],
'sticky' => $data['sticky'],
'field_short' => $data['field_short'],
'body' => $data['body'],
'field_image' => $this->importImages($data['field_image']),
'field_attach' => $this->importAttach($data['field_attach']),
'field_gallery' => $this->importImages($data['field_gallery']),
];
}
elseif ($data['type'] == 'page') {
$n = [
'uid' => 1,
'type' => $data['type'],
'title' => $data['title'],
'status' => $data['status'],
'path' => $data['path'],
'created' => $data['created'],
'changed' => $data['changed'],
'promote' => $data['promote'],
'sticky' => $data['sticky'],
'body' => $data['body'],
'field_metatag' => $data['field_metatag'],
'field_attach' => $this->importAttach($data['field_attach']),
];
}
elseif ($data['type'] == 'service') {
$n = [
'uid' => 1,
'type' => $data['type'],
'title' => $data['title'],
'status' => $data['status'],
'path' => $data['path'],
'created' => $data['created'],
'changed' => $data['changed'],
'promote' => $data['promote'],
'sticky' => $data['sticky'],
'field_service_info' => $data['field_service_info'],
'field_short' => $data['field_short'],
'field_metatag' => $data['field_metatag'],
'field_type_service' => $this->importTaxonomyField($data['field_type_service']),
'field_attach' => $this->importAttach($data['field_attach']),
'field_paragraph' => $this->importParagraph($data['field_paragraph']),
];
switch ($data['type']) {
case 'project':
$n = [
'uid' => 1,
'type' => $data['type'],
'title' => $data['title'],
'status' => $data['status'],
'path' => $data['path'],
'created' => $data['created'],
'changed' => $data['changed'],
'promote' => $data['promote'],
'sticky' => $data['sticky'],
'field_short' => $data['field_short'],
'field_size' => $data['field_size'],
'field_material' => $data['field_material'],
'field_area' => $data['field_area'],
'body' => $data['body'],
'field_count_floors' => $data['field_count_floors'],
'field_count_rooms' => $data['field_count_rooms'],
'field_price' => $data['field_price'],
'field_object_type' => $this->importTaxonomyField($data['field_object_type']),
'field_image' => $this->importImages($data['field_image']),
'field_attach' => $this->importAttach($data['field_attach']),
'field_gallery' => $this->importImages($data['field_gallery']),
];
break;
case 'portfolio':
$n = [
'uid' => 1,
'type' => $data['type'],
'title' => $data['title'],
'status' => $data['status'],
'path' => $data['path'],
'created' => $data['created'],
'changed' => $data['changed'],
'promote' => $data['promote'],
'sticky' => $data['sticky'],
'field_short' => $data['field_short'],
'body' => $data['body'],
'field_image' => $this->importImages($data['field_image']),
'field_attach' => $this->importAttach($data['field_attach']),
'field_gallery' => $this->importImages($data['field_gallery']),
];
break;
case 'page':
$n = [
'uid' => 1,
'type' => $data['type'],
'title' => $data['title'],
'status' => $data['status'],
'path' => $data['path'],
'created' => $data['created'],
'changed' => $data['changed'],
'promote' => $data['promote'],
'sticky' => $data['sticky'],
'body' => $data['body'],
'field_metatag' => $data['field_metatag'],
'field_attach' => $this->importAttach($data['field_attach']),
];
break;
case 'service':
$n = [
'uid' => 1,
'type' => $data['type'],
'title' => $data['title'],
'status' => $data['status'],
'path' => $data['path'],
'created' => $data['created'],
'changed' => $data['changed'],
'promote' => $data['promote'],
'sticky' => $data['sticky'],
'field_service_info' => $data['field_service_info'],
'field_short' => $data['field_short'],
'field_metatag' => $data['field_metatag'],
'field_type_service' => $this->importTaxonomyField($data['field_type_service']),
'field_attach' => $this->importAttach($data['field_attach']),
'field_paragraph' => $this->importParagraph($data['field_paragraph']),
];
break;
default:
$n = [
'uid' => 1,
'type' => $data['type'],
'title' => $data['title'],
'status' => $data['status'],
'path' => $data['path'],
'field_short' => $data['field_short'],
'field_metatag' => $data['field_metatag'],
'field_image' => $this->importImages($data['field_image']),
'field_paragraph' => $this->importParagraph($data['field_paragraph']),
];
break;
}
$node = $storage->create($n);
if (!empty($data['field_image_big'])) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment