You are here

function tmgmt_extension_suit_update_8004 in TMGMT Extension Suite 8

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

Create action configuration entity.

File

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

Code

function tmgmt_extension_suit_update_8004() {
  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_clear_job_items_data_action');

    // 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_clear_job_items_data_action'))
        ->save();
    }
  } catch (Exception $e) {
    throw new UpdateException('Unable to create "tmgmt_extension_suit_clear_job_items_data_action" action.');
  }
}