Loading config/schema/hp.schema.yml +3 −0 Changes for config/schema/hp.schema.yml: 3 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -4,6 +4,9 @@ hp.settings: api_key: type: string label: 'API key' status: type: boolean label: Status hp.form_plugin_configuration.*: type: hp.form_plugin_configuration Loading hp.module +10 −0 Changes for hp.module: 10 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -22,3 +22,13 @@ function hp_library_info_build() { ]; return $libraries; } /** * Implements hook_page_attachments(). */ function hp_page_attachments(array &$attachments) { $hp_status = \Drupal::config('hp.settings')->get('status'); if ($hp_status) { $attachments['#attached']['library'][] = 'hp/monitor'; } } src/SettingsForm.php +7 −0 Changes for src/SettingsForm.php: 7 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -41,6 +41,12 @@ class SettingsForm extends ConfigFormBase { '#required' => TRUE, ]; $form['status'] = [ '#type' => 'checkbox', '#title' => $this->t('Enable Human Presence monitoring via its JavaScript user interaction tracker.'), '#default_value' => $config->get('status'), ]; return $form; } Loading @@ -52,6 +58,7 @@ class SettingsForm extends ConfigFormBase { $this->config('hp.settings') ->set('api_key', $form_state->getValue('api_key')) ->set('status', $form_state->getValue('status')) ->save(); } Loading Loading
config/schema/hp.schema.yml +3 −0 Changes for config/schema/hp.schema.yml: 3 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -4,6 +4,9 @@ hp.settings: api_key: type: string label: 'API key' status: type: boolean label: Status hp.form_plugin_configuration.*: type: hp.form_plugin_configuration Loading
hp.module +10 −0 Changes for hp.module: 10 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -22,3 +22,13 @@ function hp_library_info_build() { ]; return $libraries; } /** * Implements hook_page_attachments(). */ function hp_page_attachments(array &$attachments) { $hp_status = \Drupal::config('hp.settings')->get('status'); if ($hp_status) { $attachments['#attached']['library'][] = 'hp/monitor'; } }
src/SettingsForm.php +7 −0 Changes for src/SettingsForm.php: 7 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -41,6 +41,12 @@ class SettingsForm extends ConfigFormBase { '#required' => TRUE, ]; $form['status'] = [ '#type' => 'checkbox', '#title' => $this->t('Enable Human Presence monitoring via its JavaScript user interaction tracker.'), '#default_value' => $config->get('status'), ]; return $form; } Loading @@ -52,6 +58,7 @@ class SettingsForm extends ConfigFormBase { $this->config('hp.settings') ->set('api_key', $form_state->getValue('api_key')) ->set('status', $form_state->getValue('status')) ->save(); } Loading