You are here

public function ConfigRebuildRoutes::onSave in Acquia Content Hub 8

Rebuild routes whenever we save new configuration.

Parameters

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

File

src/EventSubscriber/ConfigRebuildRoutes.php, line 42

Class

ConfigRebuildRoutes
A subscriber to rebuild routes whenever there is a change in configuration.

Namespace

Drupal\acquia_contenthub\EventSubscriber

Code

public function onSave(ConfigCrudEvent $event) {

  // Changing the content hub configuration entities that control the entity
  // types that are "exportable" to content hub requires that we rebuild
  // the routes to make those new routes available for the format
  // 'acquia_contenthub_cdf'.
  // We do not need to invalidate tags because any request coming to the
  // routes provided by acquia_contenthub are added the 'cache tag' of the
  // configuration entity that provided the response. Then if that config
  // entity is saved, its cache tag is automatically invalidated and thus
  // the response to the format 'acquia_contenthub_cdf' of the entity that
  // is served through it.
  if (strpos($event
    ->getConfig()
    ->getName(), 'acquia_contenthub.entity.') !== FALSE) {
    $this->routeBuilder
      ->setRebuildNeeded();
  }
}