You are here

function tmgmt_extension_suit_update_8006 in TMGMT Extension Suite 8

Same name and namespace in other branches
  1. 8.3 tmgmt_extension_suit.install \tmgmt_extension_suit_update_8006()
  2. 8.2 tmgmt_extension_suit.install \tmgmt_extension_suit_update_8006()

Restore "tmgmt_extension_suit_upload_job_action" action.

File

./tmgmt_extension_suit.install, line 171
Update function for the tmgmt_extension_suit module.

Code

function tmgmt_extension_suit_update_8006() {
  try {
    $entity_type_manager = \Drupal::entityTypeManager();
    $module_handler = \Drupal::moduleHandler();
    $config_install_path = $module_handler
      ->getModule('tmgmt_extension_suit')
      ->getPath() . '/' . InstallStorage::CONFIG_INSTALL_DIRECTORY;
    $action_storage = $entity_type_manager
      ->getStorage('action');
    $action = $action_storage
      ->load('tmgmt_extension_suit_upload_job_action_id');

    // Create action if it doesn't exist.
    if (!$action) {
      $storage = new FileStorage($config_install_path);
      $entity_type_manager
        ->getStorage('action')
        ->create($storage
        ->read('system.action.tmgmt_extension_suit_upload_job_action'))
        ->save();
    }
  } catch (Exception $e) {
    throw new UpdateException('Unable to create "tmgmt_extension_suit_upload_job_action" action.');
  }
}