From bf18c20e7c546e361de32dcf05b2123c995f3798 Mon Sep 17 00:00:00 2001
From: Nick Vanpraet <nickvanpraet@gmail.com>
Date: Tue, 10 Sep 2019 16:29:04 +0200
Subject: [PATCH] Changes to AssemblerForm, migrate a "home" link in demo
 config and add correct dropsolid instagram

---
 .../assets/csv/socials.csv                    |  2 +-
 ...ation.dropsolid_demo_config_menu_links.yml | 36 +++++++++++++++++++
 .../dropsolid_demo_config.module              |  1 +
 src/Form/AssemblerForm.php                    | 24 +++++++++++--
 4 files changed, 59 insertions(+), 4 deletions(-)
 create mode 100644 modules/dropsolid_demo_config/config/install/migrate_plus.migration.dropsolid_demo_config_menu_links.yml

diff --git a/modules/dropsolid_demo_config/assets/csv/socials.csv b/modules/dropsolid_demo_config/assets/csv/socials.csv
index ed9d936..9f7c8a4 100644
--- a/modules/dropsolid_demo_config/assets/csv/socials.csv
+++ b/modules/dropsolid_demo_config/assets/csv/socials.csv
@@ -1,2 +1,2 @@
 id,title,uuid,field_social_link_facebook,field_social_link_twitter,field_social_link_linkedin,field_social_link_instagram
-1,Socials,55da64d2-ed75-4038-9df0-8ec57fb06516,https://www.facebook.com/dropsolid,https://twitter.com/dropsolid,https://www.linkedin.com/company/dropsolid,https://www.instagram.com
+1,Socials,55da64d2-ed75-4038-9df0-8ec57fb06516,https://www.facebook.com/dropsolid,https://twitter.com/dropsolid,https://www.linkedin.com/company/dropsolid,https://www.instagram.com/dropsolidgent
diff --git a/modules/dropsolid_demo_config/config/install/migrate_plus.migration.dropsolid_demo_config_menu_links.yml b/modules/dropsolid_demo_config/config/install/migrate_plus.migration.dropsolid_demo_config_menu_links.yml
new file mode 100644
index 0000000..4fce508
--- /dev/null
+++ b/modules/dropsolid_demo_config/config/install/migrate_plus.migration.dropsolid_demo_config_menu_links.yml
@@ -0,0 +1,36 @@
+langcode: en
+status: true
+dependencies: { }
+id: dropsolid_demo_config_menu_links
+migration_group: dropsolid_demo_config_migrates
+label: 'Create homepage link'
+source:
+  constants:
+    node_uri_prefix: 'entity:node/'
+  plugin: embedded_data
+  data_rows:
+    -
+      id: 1
+      title: 'Home'
+      menu_name: main
+      link: 'internal:/'
+      weight: -99
+      expanded: 0
+  ids:
+    id:
+      type: integer
+process:
+  langcode:
+    plugin: callback
+    callable: rocketship_core_get_default_content_default_language
+  bundle:
+    plugin: default_value
+    default_value: menu_link_content
+  menu_name: menu_name
+  title: title
+  link/uri: link
+  weight: weight
+  expanded: expanded
+destination:
+  plugin: 'entity:menu_link_content'
+migration_dependencies: { }
diff --git a/modules/dropsolid_demo_config/dropsolid_demo_config.module b/modules/dropsolid_demo_config/dropsolid_demo_config.module
index 7397eef..d166c97 100644
--- a/modules/dropsolid_demo_config/dropsolid_demo_config.module
+++ b/modules/dropsolid_demo_config/dropsolid_demo_config.module
@@ -14,6 +14,7 @@ function _dropsolid_demo_config_migrates() {
     'dropsolid_demo_config_socials',
     'dropsolid_demo_config_usp_block',
     'dropsolid_demo_config_site_branding',
+    'dropsolid_demo_config_menu_links',
   ];
 }
 
diff --git a/src/Form/AssemblerForm.php b/src/Form/AssemblerForm.php
index 38c2ee3..afda3ab 100644
--- a/src/Form/AssemblerForm.php
+++ b/src/Form/AssemblerForm.php
@@ -8,6 +8,7 @@ use Drupal\Core\Extension\ThemeHandlerInterface;
 use Drupal\Core\Form\FormBase;
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\Core\StringTranslation\TranslationInterface;
+use Drupal\Core\Url;
 use Symfony\Component\DependencyInjection\ContainerInterface;
 
 /**
@@ -125,12 +126,29 @@ class AssemblerForm extends FormBase {
         '#tree' => FALSE,
         '#weight' => isset($module->info['weight']) ? $module->info['weight'] : 0,
       ];
+
+      // Add a link to the FA if available.
+      if (!empty($module->info['fa_link'])) {
+        $form[$filename . '_wrapper']['extra_info_wrapper'] = [
+          '#type' => 'container',
+          '#attributes' => [
+            'style' => 'display:block;margin-top:5px;',
+          ],
+        ];
+
+        $form[$filename . '_wrapper']['extra_info_wrapper']['extra_info'] = [
+          '#title' => $this->t('Functional Analysis'),
+          '#type' => 'link',
+          '#url' => Url::fromUri($module->info['fa_link'], ['attributes' => ['target' => '_blank']]),
+        ];
+      }
+
       // Add the module itself as the first module.
       $form[$filename . '_wrapper']['extra_features'][$filename] = [
         '#type' => 'checkbox',
-        '#title' => $this->t('Core'),
+        '#title' => isset($module->info['name_override']) ? $module->info['name_override'] : $this->t('Core'),
         '#description' => $this->t($module->info['description']),
-        '#default_value' => (bool) $module->status,
+        '#default_value' => (bool) empty($module->info['prechecked']) ? $module->status : $module->info['prechecked'],
         // If already enabled at this point, don't allow them to uncheck it
         // Means it's a dependency of the profile and they can't not install
         // it anyway.
@@ -150,7 +168,7 @@ class AssemblerForm extends FormBase {
             '#type' => 'checkbox',
             '#title' => $this->t($name),
             '#description' => $this->t($info->info['description']),
-            '#default_value' => (bool) $info->status,
+            '#default_value' => (bool) empty($info->info['prechecked']) ? $info->status : $info->info['prechecked'],
             '#disabled' => (bool) $info->status,
           ];
           // Add states to these upgrades if defined.
-- 
GitLab