5 * Post update functions for System.
8 use Drupal\Core\Entity\Display\EntityDisplayInterface;
9 use Drupal\Core\Entity\Entity\EntityFormDisplay;
10 use Drupal\Core\Entity\Entity\EntityViewDisplay;
13 * Re-save all configuration entities to recalculate dependencies.
15 function system_post_update_recalculate_configuration_entity_dependencies(&$sandbox = NULL) {
16 if (!isset($sandbox['config_names'])) {
17 $sandbox['config_names'] = \Drupal::configFactory()->listAll();
18 $sandbox['count'] = count($sandbox['config_names']);
20 /** @var \Drupal\Core\Config\ConfigManagerInterface $config_manager */
21 $config_manager = \Drupal::service('config.manager');
24 foreach ($sandbox['config_names'] as $key => $config_name) {
25 if ($entity = $config_manager->loadConfigEntityByName($config_name)) {
28 unset($sandbox['config_names'][$key]);
36 $sandbox['#finished'] = empty($sandbox['config_names']) ? 1 : ($sandbox['count'] - count($sandbox['config_names'])) / $sandbox['count'];
37 return t('Configuration dependencies recalculated');
41 * Update entity displays to contain the region for each field.
43 function system_post_update_add_region_to_entity_displays() {
44 $entity_save = function (EntityDisplayInterface $entity) {
45 // preSave() will fill in the correct region based on the 'type'.
48 array_map($entity_save, EntityViewDisplay::loadMultiple());
49 array_map($entity_save, EntityFormDisplay::loadMultiple());
54 * Force caches using hashes to be cleared (Twig, render cache, etc.).
56 function system_post_update_hashes_clear_cache() {
57 // Empty post-update hook.
61 * Force plugin definitions to be cleared.
63 * @see https://www.drupal.org/node/2802663
65 function system_post_update_timestamp_plugins() {
66 // Empty post-update hook.
70 * Clear caches to ensure Classy's message library is always added.
72 function system_post_update_classy_message_library() {
73 // Empty post-update hook.
77 * Force field type plugin definitions to be cleared.
79 * @see https://www.drupal.org/node/2403703
81 function system_post_update_field_type_plugins() {
82 // Empty post-update hook.