Skip to content

Commit

Permalink
UHF-9620: Install purge plugins manually
Browse files Browse the repository at this point in the history
  • Loading branch information
tuutti committed Feb 23, 2024
1 parent f1457c1 commit 57e8a43
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions helfi_proxy.install
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

0 comments on commit 57e8a43

Please sign in to comment.