Skip to content

Instantly share code, notes, and snippets.

@ahebrank
Created September 27, 2024 15:56
Show Gist options
  • Save ahebrank/de042ce7515ba832a1879ff6ec7fda3d to your computer and use it in GitHub Desktop.
Save ahebrank/de042ce7515ba832a1879ff6ec7fda3d to your computer and use it in GitHub Desktop.
diff --git a/src/EventSubscriber/StageFileProxySubscriber.php b/src/EventSubscriber/StageFileProxySubscriber.php
index b3b51bd..0199350 100644
--- a/src/EventSubscriber/StageFileProxySubscriber.php
+++ b/src/EventSubscriber/StageFileProxySubscriber.php
@@ -55,6 +55,10 @@ class StageFileProxySubscriber implements EventSubscriberInterface {
public function checkFileOrigin(RequestEvent $event) {
$config = $this->configFactory->get('stage_file_proxy.settings');
+ if ($config->get('disabled')) {
+ return;
+ }
+
// Get the origin server.
$server = $config->get('origin');
diff --git a/src/Form/SettingsForm.php b/src/Form/SettingsForm.php
index da9c91e..f9fc4d3 100644
--- a/src/Form/SettingsForm.php
+++ b/src/Form/SettingsForm.php
@@ -53,6 +53,14 @@ class SettingsForm extends ConfigFormBase {
public function buildForm(array $form, FormStateInterface $form_state, $field_type = NULL) {
$config = $this->config('stage_file_proxy.settings');
+ $form['disabled'] = [
+ '#type' => 'checkbox',
+ '#title' => $this->t('Disable proxy'),
+ '#default_value' => $config->get('disabled'),
+ '#description' => $this->t("Disable proxy. Use \$config['stage_file_proxy.settings']['disabled'] = 1; in settings.php to override module config and force disabling."),
+ '#required' => FALSE,
+ ];
+
$form['origin'] = [
'#type' => 'textfield',
'#title' => $this->t('Origin website'),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment