X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fmodules%2Fcontrib%2Fenvironment_indicator%2Fsrc%2FEnvironmentIndicatorForm.php;fp=web%2Fmodules%2Fcontrib%2Fenvironment_indicator%2Fsrc%2FEnvironmentIndicatorForm.php;h=1204b8165818811f6acce0eda638422fb7ccceb5;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hp=0000000000000000000000000000000000000000;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad;p=yaffs-website diff --git a/web/modules/contrib/environment_indicator/src/EnvironmentIndicatorForm.php b/web/modules/contrib/environment_indicator/src/EnvironmentIndicatorForm.php new file mode 100644 index 000000000..1204b8165 --- /dev/null +++ b/web/modules/contrib/environment_indicator/src/EnvironmentIndicatorForm.php @@ -0,0 +1,70 @@ +getEntity(); + + $form['name'] = [ + '#type' => 'textfield', + '#title' => t('Name'), + '#default_value' => $environment_switcher->label(), + ]; + $form['machine'] = [ + '#type' => 'machine_name', + '#machine_name' => [ + 'source' => ['name'], + 'exists' => 'environment_indicator_load', + ], + '#default_value' => $environment_switcher->id(), + '#disabled' => !empty($environment_switcher->machine), + ]; + $form['url'] = [ + '#type' => 'url', + '#title' => t('Hostname'), + '#description' => t('The hostname you want to switch to.'), + '#default_value' => $environment_switcher->getUrl(), + ]; + $form['bg_color'] = [ + '#type' => 'color', + '#title' => t('Background Color'), + '#description' => t('Background color for the indicator. Ex: #0D0D0D.'), + '#default_value' => $environment_switcher->getBgColor() ?: '#0D0D0D', + ]; + $form['fg_color'] = [ + '#type' => 'color', + '#title' => t('Color'), + '#description' => t('Color for the indicator. Ex: #D0D0D0.'), + '#default_value' => $environment_switcher->getFgColor() ?: '#D0D0D0', + ]; + + return $form; + } + + /** + * Save your config entity. + * + * There will eventually be default code to rely on here, but it doesn't exist + * yet. + */ + public function save(array $form, FormStateInterface $form_state) { + $environment = $this->getEntity(); + $environment->save(); + drupal_set_message(t('Saved the %label environment.', [ + '%label' => $environment->label(), + ])); + + $form_state->setRedirect('entity.environment_indicator.collection'); + } + +}