Drupal 9 Configurations Handling Cheat Sheet.
Shamsher Alam
Senior Solutions Specialist - Drupal @ Nasdaq | Blogger | Trainer | Drupal Enthusiast | Mentor | Drupal 7, 8, 9, 10 Acquia Certified
How to delete safely node fields programmatically.
Delete Paragraph fields and it references configs instance.
Using Drush remove module existing configs.
Drupal console
Using Hook_updates & Devel (/devel/php)
Multiple configs and selected configs import instead of all from the module.
Update All configs in single shots using Drush-eval & Devel (/devel/php)
Install the module and list of modules
Config Delete module
And if you prefer a visual way to do this, you can use my Config Delete module. Install it and then go to the /admin/config/development/configuration/delete page, choose what you want to delete and press the Delete button. If you want to install the module, this is how you can do it:
Alternate Workaround: Change Configs in the Update Hook
If you can’t use the hook_post_update_NAME workaround, there is an alternative that is well documented in the notice Support for automatic entity updates has been removed (entup). There are several code examples on how to modify configurations, but they can be pretty cumbersome, even duplicative if the configurations you need are already part of the configuration synchronization process.
There isn’t a very easy way to just import a configuration you need. That’s where the Config Importer and Tools module comes in handy. With this module you can now import configurations in just a couple lines:
$config_importer = \Drupal::service('config_import.importer'); $config_dir = \Drupal\Core\Site\Settings::get('config_sync_directory'); $config_importer->setDirectory($config_dir); $config_importer->importConfigs(['mymodule.settings’]);
The key parts are to set $config_dir to the directory containing the exported configuration files you want to import, and pass the list of configurations you want to import to importConfigs. The project page shows other examples, including how to import configurations from a module directory.
Reference:
https://www.drupal.org/docs/8/configuration-management
Thanks
Shamsher Alam
Senior Frontend || JS || React || Redux || Vue.JS || Coder @ CBRE | Mentor | Azure certified | JavaScript Enthusiastic | Mobile App Development
4 年Great