Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / core / lib / Drupal / Core / Installer / Form / SelectProfileForm.php
index 679e6db00b2ff18895c2b2a8814870091ca6c1e9..488242acee11519f400e57fb2123145d95fb56fc 100644 (file)
@@ -7,6 +7,8 @@ use Drupal\Core\Form\FormStateInterface;
 
 /**
  * Provides the profile selection form.
+ *
+ * @internal
  */
 class SelectProfileForm extends FormBase {
 
@@ -70,6 +72,11 @@ class SelectProfileForm extends FormBase {
     ];
     foreach (array_keys($names) as $profile_name) {
       $form['profile'][$profile_name]['#description'] = isset($profiles[$profile_name]['description']) ? $this->t($profiles[$profile_name]['description']) : '';
+      // @todo Remove hardcoding of 'demo_umami' profile for a generic warning
+      // system in https://www.drupal.org/project/drupal/issues/2822414.
+      if ($profile_name === 'demo_umami') {
+        $this->addUmamiWarning($form);
+      }
     }
     $form['actions'] = ['#type' => 'actions'];
     $form['actions']['submit'] = [
@@ -88,4 +95,28 @@ class SelectProfileForm extends FormBase {
     $install_state['parameters']['profile'] = $form_state->getValue('profile');
   }
 
+  /**
+   * Show profile warning if 'demo_umami' profile is selected.
+   */
+  protected function addUmamiWarning(array &$form) {
+    // Warning to show when this profile is selected.
+    $description = $form['profile']['demo_umami']['#description'];
+    // Re-defines radio #description to show warning when selected.
+    $form['profile']['demo_umami']['#description'] = [
+      'warning' => [
+        '#type' => 'item',
+        '#markup' => $this->t('This profile is intended for demonstration purposes only.'),
+        '#wrapper_attributes' => [
+          'class' => ['messages', 'messages--warning'],
+        ],
+        '#states' => [
+          'visible' => [
+            ':input[name="profile"]' => ['value' => 'demo_umami'],
+          ],
+        ],
+      ],
+      'description' => ['#markup' => $description],
+    ];
+  }
+
 }