You are here

function contact_storage_update_8002 in Contact Storage 8

Save the bulk delete action to config.

File

./contact_storage.install, line 59
Contains install and update hooks.

Code

function contact_storage_update_8002() {
  $entity_type_manager = \Drupal::entityTypeManager();
  $module_handler = \Drupal::moduleHandler();

  // Save the bulk delete action to config.
  $config_install_path = $module_handler
    ->getModule('contact_storage')
    ->getPath() . '/' . InstallStorage::CONFIG_INSTALL_DIRECTORY;

  // Create action if it doesn't exist.
  $action_storage = $entity_type_manager
    ->getStorage('action');
  $action = $action_storage
    ->load('message_delete_action');
  if (!$action) {
    $storage = new FileStorage($config_install_path);
    $entity_type_manager
      ->getStorage('action')
      ->create($storage
      ->read('system.action.message_delete_action'))
      ->save();
  }
}