function system_post_update_change_action_plugins in Drupal 8
Change plugin IDs of actions.
File
- core/
modules/ system/ system.post_update.php, line 104 - Post update functions for System.
Code
function system_post_update_change_action_plugins() {
$old_new_action_id_map = [
'comment_publish_action' => 'entity:publish_action:comment',
'comment_unpublish_action' => 'entity:unpublish_action:comment',
'comment_save_action' => 'entity:save_action:comment',
'node_publish_action' => 'entity:publish_action:node',
'node_unpublish_action' => 'entity:unpublish_action:node',
'node_save_action' => 'entity:save_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();
}
}
}