Skip to content
Snippets Groups Projects
Commit 6b4611b5 authored by Kevin Kaland's avatar Kevin Kaland
Browse files

Issue #2853800: Update endpoint, make configurable.

parent e49790a2
No related branches found
No related tags found
No related merge requests found
remote_protocol: https remote_protocol: https
# Should not contain a protocol. That's what the above is for. # 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 scheme: public
...@@ -113,3 +113,17 @@ function fillpdf_update_8104() { ...@@ -113,3 +113,17 @@ function fillpdf_update_8104() {
function fillpdf_update_8105() { function fillpdf_update_8105() {
\Drupal::getContainer()->get('module_installer')->install(['serialization']); \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.');
}
...@@ -55,7 +55,7 @@ class FillPdfSettingsForm extends ConfigFormBase { ...@@ -55,7 +55,7 @@ class FillPdfSettingsForm extends ConfigFormBase {
$options = [ $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'))]), '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'))]), '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. // Check for JavaBridge.
...@@ -82,17 +82,23 @@ class FillPdfSettingsForm extends ConfigFormBase { ...@@ -82,17 +82,23 @@ class FillPdfSettingsForm extends ConfigFormBase {
'#collapsible' => TRUE, '#collapsible' => TRUE,
'#collapsed' => $fillpdf_service !== 'fillpdf_service', '#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'] = [ $form['fillpdf_service']['fillpdf_service_api_key'] = [
'#type' => 'textfield', '#type' => 'textfield',
'#title' => $this->t('API Key'), '#title' => $this->t('API Key'),
'#default_value' => $config->get('fillpdf_service_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'] = [ $form['fillpdf_service']['remote_protocol'] = [
'#type' => 'radios', '#type' => 'radios',
'#title' => $this->t('Use HTTPS?'), '#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 '#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'), '#default_value' => $config->get('remote_protocol'),
'#options' => [ '#options' => [
'https' => $this->t('Use HTTPS'), 'https' => $this->t('Use HTTPS'),
...@@ -128,6 +134,7 @@ class FillPdfSettingsForm extends ConfigFormBase { ...@@ -128,6 +134,7 @@ class FillPdfSettingsForm extends ConfigFormBase {
// Save form values. // Save form values.
$this->config('fillpdf.settings') $this->config('fillpdf.settings')
->set('backend', $form_state->getValue('backend')) ->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('fillpdf_service_api_key', $form_state->getValue('fillpdf_service_api_key'))
->set('remote_protocol', $form_state->getValue('remote_protocol')) ->set('remote_protocol', $form_state->getValue('remote_protocol'))
->set('pdftk_path', $form_state->getValue('pdftk_path')) ->set('pdftk_path', $form_state->getValue('pdftk_path'))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment