From 6b4611b520f278022a8141fa8afdd85179916132 Mon Sep 17 00:00:00 2001 From: Kevin Kaland <kevin@wizonesolutions.com> Date: Wed, 22 Feb 2017 22:23:58 +0000 Subject: [PATCH] Issue #2853800: Update endpoint, make configurable. --- config/install/fillpdf.settings.yml | 2 +- fillpdf.install | 14 ++++++++++++++ src/Form/FillPdfSettingsForm.php | 13 ++++++++++--- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/config/install/fillpdf.settings.yml b/config/install/fillpdf.settings.yml index 7d99fd7..dce5b8d 100644 --- a/config/install/fillpdf.settings.yml +++ b/config/install/fillpdf.settings.yml @@ -1,6 +1,6 @@ remote_protocol: https # Should not contain a protocol. That's what the above is for. -remote_endpoint: fillpdf-service.com/xmlrpc.php +remote_endpoint: fillpdf.io/xmlrpc.php scheme: public diff --git a/fillpdf.install b/fillpdf.install index ffbf84e..85fdba9 100644 --- a/fillpdf.install +++ b/fillpdf.install @@ -113,3 +113,17 @@ function fillpdf_update_8104() { function fillpdf_update_8105() { \Drupal::getContainer()->get('module_installer')->install(['serialization']); } + +/** + * Update default FillPDF Service endpoint (if it's currently the default). + */ +function fillpdf_update_8106() { + $config = \Drupal::getContainer()->get('config.factory'); + $settings = $config->getEditable('fillpdf.settings'); + if ($settings->get('remote_endpoint') === 'fillpdf-service.com/xmlrpc.php') { + $settings->set('remote_endpoint', 'fillpdf.io/xmlrpc.php'); + $settings->save(); + } + + return t('Default FillPDF Service endpoint updated to fillpdf.io/xmlrpc.php.'); +} diff --git a/src/Form/FillPdfSettingsForm.php b/src/Form/FillPdfSettingsForm.php index b355920..a5a87fa 100644 --- a/src/Form/FillPdfSettingsForm.php +++ b/src/Form/FillPdfSettingsForm.php @@ -55,7 +55,7 @@ class FillPdfSettingsForm extends ConfigFormBase { $options = [ 'pdftk' => $this->t('Use locally-installed pdftk: You will need a VPS or a dedicated server so you can install pdftk: (!see_documentation).', ['!see_documentation' => $this->l($this->t('see documentation'), Url::fromUri('http://drupal.org/documentation/modules/fillpdf'))]), 'local' => $this->t('Use locally-installed PHP/JavaBridge: You will need a VPS or dedicated server so you can deploy PHP/JavaBridge on Apache Tomcat: (!see_documentation).', ['!see_documentation' => $this->l($this->t('see documentation'), Url::fromUri('http://drupal.org/documentation/modules/fillpdf'))]), - 'fillpdf_service' => $this->t('Use FillPDF Service: Sign up for <a href="https://fillpdf-service.com">FillPDF Service</a>.'), + 'fillpdf_service' => $this->t('Use FillPDF Service: Sign up for <a href="https://fillpdf.io">FillPDF Service</a>.'), ]; // Check for JavaBridge. @@ -82,17 +82,23 @@ class FillPdfSettingsForm extends ConfigFormBase { '#collapsible' => TRUE, '#collapsed' => $fillpdf_service !== 'fillpdf_service', ]; + $form['fillpdf_service']['remote_endpoint'] = [ + '#type' => 'textfield', + '#title' => $this->t('Server endpoint'), + '#default_value' => $config->get('remote_endpoint'), + '#description' => $this->t('The endpoint for the FillPDF Service instance. This does not usually need to be changed, but you may want to if you have, for example, a <a href="https://fillpdf.io/hosting">private server</a>. Do not include the protocol, as this is determined by the <em>Use HTTPS?</em> setting below.'), + ]; $form['fillpdf_service']['fillpdf_service_api_key'] = [ '#type' => 'textfield', '#title' => $this->t('API Key'), '#default_value' => $config->get('fillpdf_service_api_key'), - '#description' => $this->t('You need to sign up for an API key at <a href="https://fillpdf-service.com">FillPDF Service</a>'), + '#description' => $this->t('You need to sign up for an API key at <a href="https://fillpdf.io">FillPDF Service</a>'), ]; $form['fillpdf_service']['remote_protocol'] = [ '#type' => 'radios', '#title' => $this->t('Use HTTPS?'), '#description' => $this->t('It is recommended to select <em>Use HTTPS</em> for this option. Doing so will help prevent - sensitive information in your PDFs from being intercepted in transit between your server and the remote service.'), + sensitive information in your PDFs from being intercepted in transit between your server and the remote service. <strong>FillPDF Service will only work with HTTPS.</strong>'), '#default_value' => $config->get('remote_protocol'), '#options' => [ 'https' => $this->t('Use HTTPS'), @@ -128,6 +134,7 @@ class FillPdfSettingsForm extends ConfigFormBase { // Save form values. $this->config('fillpdf.settings') ->set('backend', $form_state->getValue('backend')) + ->set('remote_endpoint', $form_state->getValue('remote_endpoint')) ->set('fillpdf_service_api_key', $form_state->getValue('fillpdf_service_api_key')) ->set('remote_protocol', $form_state->getValue('remote_protocol')) ->set('pdftk_path', $form_state->getValue('pdftk_path')) -- GitLab