Chris@0: listAll(); Chris@0: $sandbox['count'] = count($sandbox['config_names']); Chris@0: } Chris@0: /** @var \Drupal\Core\Config\ConfigManagerInterface $config_manager */ Chris@0: $config_manager = \Drupal::service('config.manager'); Chris@0: Chris@0: $count = 0; Chris@0: foreach ($sandbox['config_names'] as $key => $config_name) { Chris@0: if ($entity = $config_manager->loadConfigEntityByName($config_name)) { Chris@0: $entity->save(); Chris@0: } Chris@0: unset($sandbox['config_names'][$key]); Chris@0: $count++; Chris@0: // Do 50 at a time. Chris@0: if ($count == 50) { Chris@0: break; Chris@0: } Chris@0: } Chris@0: Chris@0: $sandbox['#finished'] = empty($sandbox['config_names']) ? 1 : ($sandbox['count'] - count($sandbox['config_names'])) / $sandbox['count']; Chris@0: return t('Configuration dependencies recalculated'); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Update entity displays to contain the region for each field. Chris@0: */ Chris@0: function system_post_update_add_region_to_entity_displays() { Chris@0: $entity_save = function (EntityDisplayInterface $entity) { Chris@0: // preSave() will fill in the correct region based on the 'type'. Chris@0: $entity->save(); Chris@0: }; Chris@0: array_map($entity_save, EntityViewDisplay::loadMultiple()); Chris@0: array_map($entity_save, EntityFormDisplay::loadMultiple()); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Force caches using hashes to be cleared (Twig, render cache, etc.). Chris@0: */ Chris@0: function system_post_update_hashes_clear_cache() { Chris@0: // Empty post-update hook. Chris@0: } Chris@0: Chris@0: /** Chris@0: * Force plugin definitions to be cleared. Chris@0: * Chris@0: * @see https://www.drupal.org/node/2802663 Chris@0: */ Chris@0: function system_post_update_timestamp_plugins() { Chris@0: // Empty post-update hook. Chris@0: } Chris@0: Chris@0: /** Chris@0: * Clear caches to ensure Classy's message library is always added. Chris@0: */ Chris@0: function system_post_update_classy_message_library() { Chris@0: // Empty post-update hook. Chris@0: } Chris@0: Chris@0: /** Chris@0: * Force field type plugin definitions to be cleared. Chris@0: * Chris@0: * @see https://www.drupal.org/node/2403703 Chris@0: */ Chris@0: function system_post_update_field_type_plugins() { Chris@0: // Empty post-update hook. Chris@0: } Chris@14: Chris@14: /** Chris@14: * Clear caches due to schema changes in core.entity.schema.yml. Chris@14: */ Chris@14: function system_post_update_field_formatter_entity_schema() { Chris@14: // Empty post-update hook. Chris@14: } Chris@14: Chris@14: /** Chris@18: * Clear the library cache and ensure aggregate files are regenerated. Chris@18: */ Chris@18: function system_post_update_fix_jquery_extend() { Chris@18: // Empty post-update hook. Chris@18: } Chris@18: Chris@18: /** Chris@14: * Change plugin IDs of actions. Chris@14: */ Chris@14: function system_post_update_change_action_plugins() { Chris@14: $old_new_action_id_map = [ Chris@14: 'comment_publish_action' => 'entity:publish_action:comment', Chris@14: 'comment_unpublish_action' => 'entity:unpublish_action:comment', Chris@14: 'comment_save_action' => 'entity:save_action:comment', Chris@14: 'node_publish_action' => 'entity:publish_action:node', Chris@14: 'node_unpublish_action' => 'entity:unpublish_action:node', Chris@14: 'node_save_action' => 'entity:save_action:node', Chris@14: ]; Chris@14: Chris@14: /** @var \Drupal\system\Entity\Action[] $actions */ Chris@14: $actions = \Drupal::entityTypeManager()->getStorage('action')->loadMultiple(); Chris@14: foreach ($actions as $action) { Chris@14: if (isset($old_new_action_id_map[$action->getPlugin()->getPluginId()])) { Chris@14: $action->setPlugin($old_new_action_id_map[$action->getPlugin()->getPluginId()]); Chris@14: $action->save(); Chris@14: } Chris@14: } Chris@14: } Chris@17: Chris@17: /** Chris@17: * Change plugin IDs of delete actions. Chris@17: */ Chris@17: function system_post_update_change_delete_action_plugins() { Chris@17: $old_new_action_id_map = [ Chris@17: 'comment_delete_action' => 'entity:delete_action:comment', Chris@17: 'node_delete_action' => 'entity:delete_action:node', Chris@17: ]; Chris@17: Chris@17: /** @var \Drupal\system\Entity\Action[] $actions */ Chris@17: $actions = \Drupal::entityTypeManager()->getStorage('action')->loadMultiple(); Chris@17: foreach ($actions as $action) { Chris@17: if (isset($old_new_action_id_map[$action->getPlugin()->getPluginId()])) { Chris@17: $action->setPlugin($old_new_action_id_map[$action->getPlugin()->getPluginId()]); Chris@17: $action->save(); Chris@17: } Chris@17: } Chris@17: } Chris@17: Chris@17: /** Chris@17: * Force cache clear for language item callback. Chris@17: * Chris@17: * @see https://www.drupal.org/node/2851736 Chris@17: */ Chris@17: function system_post_update_language_item_callback() { Chris@17: // Empty post-update hook. Chris@17: } Chris@17: Chris@17: /** Chris@17: * Update all entity displays that contain extra fields. Chris@17: */ Chris@17: function system_post_update_extra_fields(&$sandbox = NULL) { Chris@17: $config_entity_updater = \Drupal::classResolver(ConfigEntityUpdater::class); Chris@17: $entity_field_manager = \Drupal::service('entity_field.manager'); Chris@17: Chris@17: $callback = function (EntityDisplayInterface $display) use ($entity_field_manager) { Chris@17: $display_context = $display instanceof EntityViewDisplayInterface ? 'display' : 'form'; Chris@17: $extra_fields = $entity_field_manager->getExtraFields($display->getTargetEntityTypeId(), $display->getTargetBundle()); Chris@17: Chris@17: // If any extra fields are used as a component, resave the display with the Chris@17: // updated component information. Chris@17: $needs_save = FALSE; Chris@17: if (!empty($extra_fields[$display_context])) { Chris@17: foreach ($extra_fields[$display_context] as $name => $extra_field) { Chris@17: if ($component = $display->getComponent($name)) { Chris@17: $display->setComponent($name, $component); Chris@17: $needs_save = TRUE; Chris@17: } Chris@17: } Chris@17: } Chris@17: return $needs_save; Chris@17: }; Chris@17: Chris@17: $config_entity_updater->update($sandbox, 'entity_form_display', $callback); Chris@17: $config_entity_updater->update($sandbox, 'entity_view_display', $callback); Chris@17: } Chris@17: Chris@17: /** Chris@17: * Force cache clear to ensure aggregated JavaScript files are regenerated. Chris@17: * Chris@17: * @see https://www.drupal.org/project/drupal/issues/2995570 Chris@17: */ Chris@17: function system_post_update_states_clear_cache() { Chris@17: // Empty post-update hook. Chris@17: } Chris@18: Chris@18: /** Chris@18: * Initialize 'expand_all_items' values to system_menu_block. Chris@18: */ Chris@18: function system_post_update_add_expand_all_items_key_in_system_menu_block(&$sandbox = NULL) { Chris@18: if (!\Drupal::moduleHandler()->moduleExists('block')) { Chris@18: return; Chris@18: } Chris@18: \Drupal::classResolver(ConfigEntityUpdater::class)->update($sandbox, 'block', function ($block) { Chris@18: return strpos($block->getPluginId(), 'system_menu_block:') === 0; Chris@18: }); Chris@18: } Chris@18: Chris@18: /** Chris@18: * Clear the menu cache. Chris@18: * Chris@18: * @see https://www.drupal.org/project/drupal/issues/3044364 Chris@18: */ Chris@18: function system_post_update_clear_menu_cache() { Chris@18: // Empty post-update hook. Chris@18: }