function profile_post_update_replace_view in Profile 8
Replace the "profiles" view with the updated version.
File
- ./
profile.post_update.php, line 94 - Post update functions for Profile.
Code
function profile_post_update_replace_view() {
/** @var \Drupal\Core\Config\Entity\ConfigEntityStorageInterface $view_storage */
$view_storage = \Drupal::entityTypeManager()
->getStorage('view');
/** @var \Drupal\Core\Config\Entity\ConfigEntityInterface $view */
$view = $view_storage
->load('profiles');
if (!$view) {
return;
}
$config_storage = \Drupal::service('config.storage');
$extension_config_storage = new ExtensionInstallStorage($config_storage, InstallStorage::CONFIG_INSTALL_DIRECTORY, StorageInterface::DEFAULT_COLLECTION, TRUE, NULL);
$config_data = $extension_config_storage
->read('views.view.profiles');
$view
->setSyncing(TRUE);
// The UUID must remain unchanged between updates.
$uuid = $view
->uuid();
$view = $view_storage
->updateFromStorageRecord($view, $config_data);
$view
->set('uuid', $uuid);
$view
->save();
}