You are here

function system_post_update_change_delete_action_plugins in Drupal 8

Change plugin IDs of delete actions.

File

core/modules/system/system.post_update.php, line 127
Post update functions for System.

Code

function system_post_update_change_delete_action_plugins() {
  $old_new_action_id_map = [
    'comment_delete_action' => 'entity:delete_action:comment',
    'node_delete_action' => 'entity:delete_action:node',
  ];

  /** @var \Drupal\system\Entity\Action[] $actions */
  $actions = \Drupal::entityTypeManager()
    ->getStorage('action')
    ->loadMultiple();
  foreach ($actions as $action) {
    if (isset($old_new_action_id_map[$action
      ->getPlugin()
      ->getPluginId()])) {
      $action
        ->setPlugin($old_new_action_id_map[$action
        ->getPlugin()
        ->getPluginId()]);
      $action
        ->save();
    }
  }
}