diff --git a/modules/quant_api/src/Client/QuantClient.php b/modules/quant_api/src/Client/QuantClient.php
index aa13895d..b5469486 100644
--- a/modules/quant_api/src/Client/QuantClient.php
+++ b/modules/quant_api/src/Client/QuantClient.php
@@ -17,6 +17,13 @@
*/
class QuantClient implements QuantClientInterface {
+ /**
+ * The configuration object for Quant API.
+ *
+ * @var \Drupal\Core\Config\ImmutableConfig
+ */
+ protected $config;
+
/**
* The logger service.
*
@@ -63,15 +70,40 @@ class QuantClient implements QuantClientInterface {
* {@inheritdoc}
*/
public function __construct(Client $client, ConfigFactoryInterface $config_factory, LoggerChannelFactoryInterface $logger_factory) {
- $config = $config_factory->get('quant_api.settings');
+ $this->config = $config_factory->get('quant_api.settings');
$this->client = $client;
$this->logger = $logger_factory->get('quant_api');
- $this->username = $config->get('api_account');
- $this->token = $config->get('api_token');
- $this->project = $config->get('api_project');
- $this->endpoint = $config->get('api_endpoint') . '/v1';
- $this->tlsDisabled = $config->get('api_tls_disabled');
+ $this->username = $this->config->get('api_account');
+ $this->token = $this->config->get('api_token');
+ $this->project = $this->config->get('api_project');
+ $this->endpoint = $this->config->get('api_endpoint') . '/v1';
+ $this->tlsDisabled = $this->config->get('api_tls_disabled');
+ }
+
+ /**
+ * Get API overrides.
+ */
+ public function getOverrides() {
+ // Note this has to be processed in this class instead of in the
+ // SettingsForm because the overrides aren't available in the form.
+ $overrides = [];
+ $keys = [
+ 'api_endpoint',
+ 'api_account',
+ 'api_project',
+ 'api_token',
+ 'api_tls_disabled',
+ ];
+ foreach ($keys as $key) {
+ $original = $this->config->getOriginal($key, FALSE);
+ $active = $this->config->get($key);
+ if ($original != $active) {
+ $overrides[$key] = $active;
+ }
+ }
+
+ return $overrides;
}
/**
diff --git a/modules/quant_api/src/Form/SettingsForm.php b/modules/quant_api/src/Form/SettingsForm.php
index a2b90db6..bb086795 100644
--- a/modules/quant_api/src/Form/SettingsForm.php
+++ b/modules/quant_api/src/Form/SettingsForm.php
@@ -101,10 +101,35 @@ public function buildForm(array $form, FormStateInterface $form_state) {
$form['api_tls_disabled'] = [
'#type' => 'checkbox',
'#title' => $this->t('Disable TLS verification'),
- '#description' => $this->t('You can optionally disable SSL verification for all Quant API requests. This is not recommended, but may be necessary in some configurations. For example, old web servers may have issues validating modern SSL certificates.'),
+ '#description' => $this->t('You can optionally disable TLS verification for all Quant API requests. This is not recommended, but may be necessary in some configurations. For example, old web servers may have issues validating modern TSL/SSL certificates.'),
'#default_value' => $config->get('api_tls_disabled', FALSE),
];
+ // API values might be overridden in the settings file.
+ $overrides = $this->client->getOverrides();
+ foreach ($overrides as $key => $value) {
+ if ($key === 'api_token') {
+ // Don't show the token in the UI.
+ $message = $this->t('QuantAPI override: api_token
has been overridden in the settings file.');
+ }
+ else {
+ $message = $this->t('QuantAPI override: @key has been overridden in the settings file with @value.',
+ [
+ '@key' => $key,
+ '@value' => $value,
+ ]);
+ }
+
+ // Show warning and add to description.
+ \Drupal::messenger()->addWarning($message);
+ $form[$key]['#description'] = $form[$key]['#description'] . ' ' . $message . '';
+ }
+
+ // Show error if not using TSL verification.
+ if ((isset($overrides['api_tls_disabled']) && !$overrides['api_tls_disabled']) || !$config->get('api_tls_disabled')) {
+ \Drupal::messenger()->addError($this->t('DANGER ZONE: TLS verification is disabled for Quant API connections. It is highly recommended that you update your server configuration to handle TLS rather than disabling TLS verification.'));
+ }
+
return parent::buildForm($form, $form_state);
}
diff --git a/quant.module b/quant.module
index 77f469e9..8f5c9a90 100644
--- a/quant.module
+++ b/quant.module
@@ -412,6 +412,10 @@ function quant_modules_uninstalled($modules) {
* The path alias.
*/
function quant_path_alias_presave(EntityInterface $pathAlias) {
+ if (!$pathAlias || !$pathAlias->original) {
+ return;
+ }
+
// Original path alias.
$original_path = $pathAlias->original->get('path')->value;
$original_alias = $pathAlias->original->get('alias')->value;
diff --git a/src/Utility.php b/src/Utility.php
index 7181f2ae..dc1fa77c 100644
--- a/src/Utility.php
+++ b/src/Utility.php
@@ -142,55 +142,63 @@ public static function processDrafts() {
* The markup with the page info.
*/
public static function getPageInfo(array $urls = NULL) : string {
- // Default to the current page.
- if (!$urls) {
- $urls = [self::getUrl()];
- }
-
- $client = \Drupal::service('quant_api.client');
- $response = $client->getUrlMeta($urls);
-
- if (isset($response['global_meta']['records'])) {
- // Show meta information for the pages in Quant.
- $found_urls = [];
- $output = '