From 57e8a434452b0bb1b8a9543cb5cb60285aa7c1fa Mon Sep 17 00:00:00 2001 From: tuutti Date: Fri, 23 Feb 2024 08:55:44 +0200 Subject: [PATCH] UHF-9620: Install purge plugins manually --- helfi_proxy.install | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/helfi_proxy.install b/helfi_proxy.install index 44d156c..5f0573d 100644 --- a/helfi_proxy.install +++ b/helfi_proxy.install @@ -36,4 +36,30 @@ function helfi_proxy_update_9002() : void { /** @var \Drupal\Core\Config\ConfigInstallerInterface $configInstaller */ $configInstaller = \Drupal::service('config.installer'); $configInstaller->installDefaultConfig('module', 'helfi_proxy'); + + // Re-installing the default configuration does not install purge configuration + // for some reason. + $plugins = \Drupal::configFactory()->getEditable('purge.plugins'); + $purgers = $plugins->get('purgers'); + + if (!array_filter($purgers, fn (array $item) => $item['instance_id'] === 'assets')) { + $purgers[] = [ + 'instance_id' => 'assets', + 'plugin_id' => 'varnish', + 'order_index' => 4, + ]; + $plugins->set('purgers', $purgers) + ->save(); + } + $loggers = \Drupal::configFactory()->getEditable('purge.logger_channels'); + $channels = $loggers->get('channels'); + + if (!array_filter($channels, fn (array $item) => $item['id'] === 'purger_varnish_assets')) { + $channels[] = [ + 'id' => 'purger_varnish_assets', + 'grants' => [0, 2, 3], + ]; + } + $loggers->set('channels', $channels) + ->save(); }