diff -u b/core/profiles/demo_umami/modules/demo_umami_content/default_content/languages/en/block_content/banner_block.csv b/core/profiles/demo_umami/modules/demo_umami_content/default_content/languages/en/block_content/banner_block.csv
--- b/core/profiles/demo_umami/modules/demo_umami_content/default_content/languages/en/block_content/banner_block.csv
+++ b/core/profiles/demo_umami/modules/demo_umami_content/default_content/languages/en/block_content/banner_block.csv
@@ -1,3 +1,3 @@
-id,uuid,info,type,field_title,field_content_link_content,field_content_link_title,field_summary,field_banner_image_target_id,field_banner_image_alt
-umami_home_banner,9aadf4a1-ded6-4017-a10d-a5e043396edf,"Umami Home Banner",banner_block,"Super easy vegetarian pasta bake","Super easy vegetarian pasta bake","View recipe","A wholesome pasta bake is the ultimate comfort food. This delicious bake is super quick to prepare and an ideal midweek meal for all the family.",veggie-pasta-bake-hero-umami.jpg,"Mouth watering vegetarian pasta bake with rich tomato sauce and cheese toppings"
-umami_recipes_banner,4c7d58a3-a45d-412d-9068-259c57e40541,"Umami Recipes Banner",banner_block,"Vegan chocolate and nut brownies","Vegan chocolate and nut brownies","View recipe","These sumptuous brownies should be gooey on the inside and crisp on the outside. A perfect indulgence!",vegan-brownies-hero-umami.jpg,"A stack of chocolate and pecan brownies, sprinkled with pecan crumbs and crushed walnut, fresh out of the oven"
+id,uuid,info,type,field_title,content_type,node_id,field_content_link_title,field_summary,field_banner_image_target_id,field_banner_image_alt
+umami_home_banner,9aadf4a1-ded6-4017-a10d-a5e043396edf,"Umami Home Banner",banner_block,"Super easy vegetarian pasta bake",recipe,3,"View recipe","A wholesome pasta bake is the ultimate comfort food. This delicious bake is super quick to prepare and an ideal midweek meal for all the family.",veggie-pasta-bake-hero-umami.jpg,"Mouth watering vegetarian pasta bake with rich tomato sauce and cheese toppings"
+umami_recipes_banner,4c7d58a3-a45d-412d-9068-259c57e40541,"Umami Recipes Banner",banner_block,"Vegan chocolate and nut brownies",recipe,2,"View recipe","These sumptuous brownies should be gooey on the inside and crisp on the outside. A perfect indulgence!",vegan-brownies-hero-umami.jpg,"A stack of chocolate and pecan brownies, sprinkled with pecan crumbs and crushed walnut, fresh out of the oven"
diff -u b/core/profiles/demo_umami/modules/demo_umami_content/default_content/languages/en/block_content/footer_promo_block.csv b/core/profiles/demo_umami/modules/demo_umami_content/default_content/languages/en/block_content/footer_promo_block.csv
--- b/core/profiles/demo_umami/modules/demo_umami_content/default_content/languages/en/block_content/footer_promo_block.csv
+++ b/core/profiles/demo_umami/modules/demo_umami_content/default_content/languages/en/block_content/footer_promo_block.csv
@@ -1,2 +1,2 @@
-id,uuid,info,type,field_title,field_content_link_content,field_content_link_title,field_summary,field_promo_image_target_id,field_promo_image_alt
-umami_footer_promo,924ab293-8f5f-45a1-9c7f-2423ae61a241,"Umami footer promo",footer_promo_block,"Umami Food Magazine","About Umami","Find out more","Skills and know-how. Magazine exclusive articles, recipes and plenty of reasons to get your copy today.",umami-bundle.png,"3 issue bundle of the Umami food magazine"
+id,uuid,info,type,field_title,content_type,node_id,field_content_link_title,field_summary,field_promo_image_target_id,field_promo_image_alt
+umami_footer_promo,924ab293-8f5f-45a1-9c7f-2423ae61a241,"Umami footer promo",footer_promo_block,"Umami Food Magazine",page,1,"Find out more","Skills and know-how. Magazine exclusive articles, recipes and plenty of reasons to get your copy today.",umami-bundle.png,"3 issue bundle of the Umami food magazine"
diff -u b/core/profiles/demo_umami/modules/demo_umami_content/default_content/languages/es/block_content/banner_block.csv b/core/profiles/demo_umami/modules/demo_umami_content/default_content/languages/es/block_content/banner_block.csv
--- b/core/profiles/demo_umami/modules/demo_umami_content/default_content/languages/es/block_content/banner_block.csv
+++ b/core/profiles/demo_umami/modules/demo_umami_content/default_content/languages/es/block_content/banner_block.csv
@@ -1,3 +1,3 @@
-id,uuid,info,type,field_title,field_content_link_content,field_content_link_title,field_summary,field_banner_image_target_id,field_banner_image_alt
-umami_home_banner,9aadf4a1-ded6-4017-a10d-a5e043396edf,"Spanish-Umami Home Banner",banner_block,"Spanish-Super easy vegetarian pasta bake","Super easy vegetarian pasta bake","Spanish-View recipe","A wholesome pasta bake is the ultimate comfort food. This delicious bake is super quick to prepare and an ideal midweek meal for all the family.",veggie-pasta-bake-hero-umami.jpg,"Mouth watering vegetarian pasta bake with rich tomato sauce and cheese toppings"
-umami_recipes_banner,4c7d58a3-a45d-412d-9068-259c57e40541,"Spanish-Umami Recipes Banner",banner_block,"Spanish-Vegan chocolate and nut brownies","Vegan chocolate and nut brownies","Spanish-View recipe","These sumptuous brownies should be gooey on the inside and crisp on the outside. A perfect indulgence!",vegan-brownies-hero-umami.jpg,"A stack of chocolate and pecan brownies, sprinkled with pecan crumbs and crushed walnut, fresh out of the oven"
+id,uuid,info,type,field_title,content_type,node_id,field_content_link_title,field_summary,field_banner_image_target_id,field_banner_image_alt
+umami_home_banner,9aadf4a1-ded6-4017-a10d-a5e043396edf,"Umami Casa Pancarta",banner_block,"Pasta vegetariana horneada súper fácil",recipe,4,"Ver receta","Una pasta al horno es la comida más reconfortante que hay. Este plato al horno es súper rápido de preparar y es ideal para cocinar entre semana para toda la familia.",veggie-pasta-bake-hero-umami.jpg,"Pasta vegetariana al horno con una rica salsa de tomate cubierta de queso que hará que se te haga la boca agua."
+umami_recipes_banner,4c7d58a3-a45d-412d-9068-259c57e40541,"Umami Recetas Pancarta",banner_block,"Brownies Veganos de Chocolate y Nuez",recipe,6,"Ver receta","Estos exquisitos brownies quedarán sabrosos por dentro y crujientes por fuera. ¡La tentación perfecta!",vegan-brownies-hero-umami.jpg,"Una torre de brownies de chocolate y nueces pecanas, espolvoreadas con pedacitos de nueces pecanas y avellanas, recién salida del horno."
diff -u b/core/profiles/demo_umami/modules/demo_umami_content/default_content/languages/es/block_content/disclaimer_block.csv b/core/profiles/demo_umami/modules/demo_umami_content/default_content/languages/es/block_content/disclaimer_block.csv
--- b/core/profiles/demo_umami/modules/demo_umami_content/default_content/languages/es/block_content/disclaimer_block.csv
+++ b/core/profiles/demo_umami/modules/demo_umami_content/default_content/languages/es/block_content/disclaimer_block.csv
@@ -2 +2 @@
-umami_disclaimer,9b4dcd67-99f3-48d0-93c9-2c46648b29de,"Spanish-Umami Disclaimer",disclaimer_block,"Spanish-Umami Magazine & Umami Publications is a fictional magazine and publisher for illustrative purposes only.","Terms & Conditions"
+umami_disclaimer,9b4dcd67-99f3-48d0-93c9-2c46648b29de,"Aviso Legal Umami",disclaimer_block,"Revista Umami y Publicaciones Umami es una revista ficticia publicada con propósito ilustrativo sólamente.","Términos y Condiciones"
diff -u b/core/profiles/demo_umami/modules/demo_umami_content/default_content/languages/es/block_content/footer_promo_block.csv b/core/profiles/demo_umami/modules/demo_umami_content/default_content/languages/es/block_content/footer_promo_block.csv
--- b/core/profiles/demo_umami/modules/demo_umami_content/default_content/languages/es/block_content/footer_promo_block.csv
+++ b/core/profiles/demo_umami/modules/demo_umami_content/default_content/languages/es/block_content/footer_promo_block.csv
@@ -1,2 +1,2 @@
-id,uuid,info,type,field_title,field_content_link_content,field_content_link_title,field_summary,field_promo_image_target_id,field_promo_image_alt
-umami_footer_promo,924ab293-8f5f-45a1-9c7f-2423ae61a241,"Spanish-Umami footer promo",footer_promo_block,"Spanish-Umami Food Magazine","About Umami","Spanish-Find out more","Skills and know-how. Magazine exclusive articles, recipes and plenty of reasons to get your copy today.",umami-bundle.png,"3 issue bundle of the Umami food magazine"
+id,uuid,info,type,field_title,content_type,node_id,field_content_link_title,field_summary,field_promo_image_target_id,field_promo_image_alt
+umami_footer_promo,924ab293-8f5f-45a1-9c7f-2423ae61a241,"Umami Pie de Pagina Promocional",footer_promo_block,"Revista de Comida Umami",page,1,"Más información","Trucos y consejos. Artículos exclusivos de la revista, recetas y una variedad de razones para conseguir tu copia hoy.",umami-bundle.png,"Paquete de 3 ediciones de la revista de comida Umami"
diff -u b/core/profiles/demo_umami/modules/demo_umami_content/src/InstallHelper.php b/core/profiles/demo_umami/modules/demo_umami_content/src/InstallHelper.php
--- b/core/profiles/demo_umami/modules/demo_umami_content/src/InstallHelper.php
+++ b/core/profiles/demo_umami/modules/demo_umami_content/src/InstallHelper.php
@@ -68,4 +68,14 @@
/**
+ * Node ID map.
+ *
+ * Used to store node IDs created in the import process. This allows the created nodes
+ * to be cross referenced when creating blocks.
+ *
+ * @var array
+ */
+ protected $nodeIdMap;
+
+ /**
* Constructs a new InstallHelper object.
*
@@ -87,6 +97,7 @@
$this->state = $state;
$this->fileSystem = $fileSystem;
$this->termIdMap = [];
+ $this->nodeIdMap = [];
}
/**
@@ -116,9 +127,9 @@
->importContentFromFile('node', 'recipe')
->importContentFromFile('node', 'article')
->importContentFromFile('node', 'page')
- ->importContentFromFile('block_content', 'banner_block')
->importContentFromFile('block_content', 'disclaimer_block')
- ->importContentFromFile('block_content', 'footer_promo_block');
+ ->importContentFromFile('block_content', 'footer_promo_block')
+ ->importContentFromFile('block_content', 'banner_block');
}
/**
@@ -180,7 +191,7 @@
$keyed_content[$translated_language][$index] = array_combine($header, $content);
}
}
- return [$keyed_content, $translated_languages];
+ return array($keyed_content, $translated_languages);
}
/**
@@ -215,6 +226,34 @@
$this->termIdMap[$vocabulary][$term_csv_id] = $tid;
}
+ /**
+ * Retrieves the Node path of Node ID saved during the import process.
+ *
+ * @param int $node_id
+ * The node's ID from the CSV file.
+ *
+ * @return string
+ * Node path, or 0 if Node ID could not be found.
+ */
+ protected function getNodePath($content_type, $node_id) {
+ if (array_key_exists($content_type, $this->nodeIdMap) && array_key_exists($node_id, $this->nodeIdMap[$content_type])) {
+ return $this->nodeIdMap[$content_type][$node_id];
+ }
+ return 0;
+ }
+
+ /**
+ * Saves a node ID generated when saving content.
+ *
+ * @param string $node_id
+ * The node's ID from the CSV file.
+ * @param string $node_url
+ * Node's alias url when saved in the Drupal database.
+ */
+ protected function saveNodePath($content_type, $node_id, $node_url) {
+ $this->nodeIdMap[$content_type][$node_id] = $node_url;
+ }
+
/**
* Imports editors.
*
@@ -293,6 +332,9 @@
if (!empty($data['slug'])) {
$values['path'] = [['alias' => '/' . $data['slug']]];
}
+ // Save node alias
+ $this->saveNodePath('page', $data['id'], $data['slug']);
+
// Set article author.
if (!empty($data['author'])) {
$values['uid'] = $this->getUser($data['author']);
@@ -327,6 +369,9 @@
if (!empty($data['slug'])) {
$values['path'] = [['alias' => '/' . $data['slug']]];
}
+ // Save node alias
+ $this->saveNodePath('recipe', $data['id'], $data['slug']);
+
// Set field_image field.
if (!empty($data['image'])) {
$image_path = $module_path . '/default_content/images/' . $data['image'];
@@ -427,6 +472,8 @@
if (!empty($data['slug'])) {
$values['path'] = [['alias' => '/' . $data['slug']]];
}
+ // Save node alias
+ $this->saveNodePath('article', $data['id'], $data['slug']);
// Set article author.
if (!empty($data['author'])) {
$values['uid'] = $this->getUser($data['author']);
@@ -464,10 +511,7 @@
* Data structured as a block.
*/
protected function processBannerBlock($module_path, array $data) {
-
- $nodes = $this->entityTypeManager->getStorage('node')->loadByProperties(['title' => $data['field_content_link_content']]);
- $node = reset($nodes);
- $node_of_field_title = $this->aliasManager->getAliasByPath('/node/' . $node->id());
+ $node_url = $this->getNodePath($data['content_type'],$data['node_id']);
$values = [
'uuid' => $data['uuid'],
'info' => $data['info'],
@@ -476,7 +520,7 @@
'value' => $data['field_title'],
],
'field_content_link' => [
- 'uri' => 'internal:' . $node_of_field_title,
+ 'uri' => 'internal:/' . $node_url,
'title' => $data['field_content_link_title'],
],
'field_summary' => [
@@ -509,9 +553,7 @@
}
protected function processFooterPromoBlock($module_path, array $data) {
- $nodes = $this->entityTypeManager->getStorage('node')->loadByProperties(['title' => $data['field_content_link_content']]);
- $node = reset($nodes);
- $node_of_field_title = $this->aliasManager->getAliasByPath('/node/' . $node->id());
+ $node_url = $this->getNodePath($data['content_type'],$data['node_id']);
$values = [
'uuid' => $data['uuid'],
'info' => $data['info'],
@@ -520,7 +562,7 @@
'value' => $data['field_title'],
],
'field_content_link' => [
- 'uri' => 'internal:' . $node_of_field_title,
+ 'uri' => 'internal:/' . $node_url,
'title' => $data['field_content_link_title'],
],
'field_summary' => [
@@ -534,89 +576,6 @@
return $values;
}
- /**
- * Process block_banner data into block_banner block structure.
- *
- * @param string $module_path
- * Path of this module
- * @param array $data
- * Data of line that was read from the file.
- *
- * @return array
- * Data structured as a block.
- */
- protected function processBlock($module_path, array $data, $block_type) {
-
- switch ($block_type) {
- case 'banner_block':
- $nodes = $this->entityTypeManager->getStorage('node')->loadByProperties(['title' => $data['field_content_link_content']]);
- $node = reset($nodes);
- $node_of_field_title = $this->aliasManager->getAliasByPath('/node/' . $node->id());
- $values = [
- 'uuid' => $data['uuid'],
- 'info' => $data['info'],
- 'type' => $data['type'],
- 'field_title' => [
- 'value' => $data['field_title'],
- ],
- 'field_content_link' => [
- 'uri' => 'internal:' . $node_of_field_title,
- 'title' => $data['field_content_link_title'],
- ],
- 'field_summary' => [
- 'value' => $data['field_summary'],
- ],
- 'field_banner_image' => [
- 'target_id' => $this->createFileEntity($module_path . '/default_content/images/' . $data['field_banner_image_target_id']),
- 'alt' => $data['field_banner_image_alt'],
- ],
- ];
- break;
- case 'disclaimer_block':
- $values = [
- 'uuid' => $data['uuid'],
- 'info' => $data['info'],
- 'type' => $data['type'],
- 'field_disclaimer' => [
- 'value' => $data['field_disclaimer'],
- 'format' => 'basic_html',
- ],
- 'field_copyright' => [
- 'value' => '© ' . date("Y") . ' ' . $data['field_copyright'],
- 'format' => 'basic_html',
- ],
- ];
- break;
- case 'footer_promo_block':
- $nodes = $this->entityTypeManager->getStorage('node')->loadByProperties(['title' => $data['field_content_link_content']]);
- $node = reset($nodes);
- $node_of_field_title = $this->aliasManager->getAliasByPath('/node/' . $node->id());
- $values = [
- 'uuid' => $data['uuid'],
- 'info' => $data['info'],
- 'type' => $data['type'],
- 'field_title' => [
- 'value' => $data['field_title'],
- ],
- 'field_content_link' => [
- 'uri' => 'internal:' . $node_of_field_title,
- 'title' => $data['field_content_link_title'],
- ],
- 'field_summary' => [
- 'value' => $data['field_summary'],
- ],
- 'field_promo_image' => [
- 'target_id' => $this->createFileEntity($module_path . '/default_content/images/' . $data['field_promo_image_target_id']),
- 'alt' => $data['field_promo_image_alt'],
- ],
- ];
- break;
- default:
- break;
- }
- return $values;
- }
-
/**
* Imports content.
*
only in patch2:
unchanged:
--- /dev/null
+++ b/core/profiles/demo_umami/config/install/language.content_settings.block_content.banner_block.yml
@@ -0,0 +1,15 @@
+langcode: en
+status: true
+dependencies:
+ config:
+ - block_content.type.banner_block
+ module:
+ - content_translation
+third_party_settings:
+ content_translation:
+ enabled: true
+id: block_content.banner_block
+target_entity_type_id: block_content
+target_bundle: banner_block
+default_langcode: site_default
+language_alterable: true
only in patch2:
unchanged:
--- /dev/null
+++ b/core/profiles/demo_umami/config/install/language.content_settings.block_content.basic.yml
@@ -0,0 +1,15 @@
+langcode: en
+status: true
+dependencies:
+ config:
+ - block_content.type.basic
+ module:
+ - content_translation
+third_party_settings:
+ content_translation:
+ enabled: true
+id: block_content.basic
+target_entity_type_id: block_content
+target_bundle: basic
+default_langcode: site_default
+language_alterable: true
only in patch2:
unchanged:
--- /dev/null
+++ b/core/profiles/demo_umami/config/install/language.content_settings.block_content.disclaimer_block.yml
@@ -0,0 +1,15 @@
+langcode: en
+status: true
+dependencies:
+ config:
+ - block_content.type.disclaimer_block
+ module:
+ - content_translation
+third_party_settings:
+ content_translation:
+ enabled: true
+id: block_content.disclaimer_block
+target_entity_type_id: block_content
+target_bundle: disclaimer_block
+default_langcode: site_default
+language_alterable: true
only in patch2:
unchanged:
--- /dev/null
+++ b/core/profiles/demo_umami/config/install/language.content_settings.block_content.footer_promo_block.yml
@@ -0,0 +1,15 @@
+langcode: en
+status: true
+dependencies:
+ config:
+ - block_content.type.footer_promo_block
+ module:
+ - content_translation
+third_party_settings:
+ content_translation:
+ enabled: true
+id: block_content.footer_promo_block
+target_entity_type_id: block_content
+target_bundle: footer_promo_block
+default_langcode: site_default
+language_alterable: true