function hook_post_update_NAME
Same name and namespace in other branches
- 9 core/lib/Drupal/Core/Extension/module.api.php \hook_post_update_NAME()
- 8.9.x core/lib/Drupal/Core/Extension/module.api.php \hook_post_update_NAME()
- 10 core/lib/Drupal/Core/Extension/module.api.php \hook_post_update_NAME()
Related topics
33 functions implement hook_post_update_NAME()
Note: the procedural functions in this list are found by pattern matching, so the list may include some functions that are not actually implementations of this hook.
- block_post_update_make_weight_integer in core/
modules/ block/ block.post_update.php - Ensures that all block weights are integers.
- block_post_update_set_menu_block_depth_to_null_if_zero in core/
modules/ block/ block.post_update.php - Updates the `depth` setting to NULL if it is 0 in any menu blocks.
- file_post_update_add_playsinline in core/
modules/ file/ file.post_update.php - Adds a value for the 'playsinline' setting of the 'file_video' formatter.
- forum_post_update_recreate_forum_index_rows in core/
modules/ forum/ forum.post_update.php - Repopulate the forum index table.
- media_post_update_media_author_views_filter_update in core/
modules/ media/ media.post_update.php - Empty update function to clear the Views data cache.
File
-
core/
lib/ Drupal/ Core/ Extension/ module.api.php, line 899
Code
function hook_post_update_NAME(&$sandbox) {
// Example of updating some content.
$node = \Drupal\node\Entity\Node::load(123);
$node->setTitle('foo');
$node->save();
$result = t('Node %nid saved', [
'%nid' => $node->id(),
]);
// Example of updating some config.
if (\Drupal::moduleHandler()->moduleExists('taxonomy')) {
// Update the dependencies of all Vocabulary configuration entities.
\Drupal::classResolver(\Drupal\Core\Config\Entity\ConfigEntityUpdater::class)->update($sandbox, 'taxonomy_vocabulary');
}
return $result;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.