public function ExtlinkSettingsSaveEventSubscriber::onConfigSave in External Links 8
Acts on changes to extlink.settings to flush JS library and assets.
Parameters
\Drupal\Core\Config\ConfigCrudEvent $event: The configuration event.
File
- src/
EventSubscriber/ ExtlinkSettingsSaveEventSubscriber.php, line 49
Class
- ExtlinkSettingsSaveEventSubscriber
- Clears JS and asset libraries in response to changes in extlink settings.
Namespace
Drupal\extlink\EventSubscriberCode
public function onConfigSave(ConfigCrudEvent $event) {
$config = $event
->getConfig();
if ($config
->getName() === 'extlink.settings') {
$flush_js_files = $config
->get('extlink_use_external_js_file');
if ($event
->isChanged('extlink_use_external_js_file')) {
// When using external JS file is enabled or disabled, need to flush the
// library discovery cache to update the dependencies of drupal.extlink
// library.
$this->libraryDiscovery
->clearCachedDefinitions();
$flush_js_files = TRUE;
}
if ($flush_js_files) {
// Flush the optimized JS files if using an external JS file when the
// settings are saved. Also flush the optimized JS files when disabling
// or enabling using the external JS files.
$this->jsOptimizer
->deleteAll();
_drupal_flush_css_js();
}
}
}