You are here

public function ConfigSubscriber::onSave in HTTP/2 Server Push 8

Invalidates all render caches when CSS/JS aggregation gets toggled.

Parameters

\Drupal\Core\Config\ConfigCrudEvent $event: The Event to process.

File

src/EventSubscriber/ConfigSubscriber.php, line 60

Class

ConfigSubscriber
Invalidates cache tags & rebuilds container when necessary.

Namespace

Drupal\http2_server_push\EventSubscriber

Code

public function onSave(ConfigCrudEvent $event) {
  if ($this->configInstaller
    ->isSyncing()) {
    return;
  }
  if ($event
    ->getConfig()
    ->getName() !== 'system.performance') {
    return;
  }
  if (!$event
    ->isChanged('css.preprocess') && !$event
    ->isChanged('js.preprocess')) {
    return;
  }
  $this->cacheTagsInvalidator
    ->invalidateTags([
    // Rendered output that is cached. (HTML containing Link headers.)
    'rendered',
  ]);

  // Rebuild the container whenever CSS/JS aggregation gets toggled.
  // @see \Drupal\http2_server_push\Http2ServerPushServiceProvider
  $this->drupalKernel
    ->invalidateContainer();
}