You are here

public function ConfigSubscriber::onConfigDelete in Autosave Form 8

Purges all autosave states in case a form-related config is deleted.

Parameters

\Drupal\Core\Config\ConfigCrudEvent $event: The configuration event.

File

src/EventSubscriber/ConfigSubscriber.php, line 107

Class

ConfigSubscriber
Purges autosave states on configuration changes.

Namespace

Drupal\autosave_form\EventSubscriber

Code

public function onConfigDelete(ConfigCrudEvent $event) {
  $deleted_config = $event
    ->getConfig();
  $name = $deleted_config
    ->getName();
  $purge_autosave_states = strpos($name, 'field.field.') === 0 || strpos($name, 'field.storage.') === 0 || strpos($name, 'core.entity_form_display.') === 0 || strpos($name, 'user.role.') === 0;
  if ($purge_autosave_states) {
    $this->autosaveEntityFormStorage
      ->purgeAutosavedEntitiesStates();
  }
}