Drupal 9 Configurations Handling Cheat Sheet.
Drupal 9 Cheat Sheets For Play with Configs.

Drupal 9 Configurations Handling Cheat Sheet.

How to delete safely node fields programmatically.

No alt text provided for this image

Delete Paragraph fields and it references configs instance.

No alt text provided for this image

Using Drush remove module existing configs.

No alt text provided for this image

Drupal console

No alt text provided for this image

Using Hook_updates & Devel (/devel/php)

No alt text provided for this image

Multiple configs and selected configs import instead of all from the module.

No alt text provided for this image
No alt text provided for this image

Update All configs in single shots using Drush-eval & Devel (/devel/php)

No alt text provided for this image

Install the module and list of modules

No alt text provided for this image

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:

No alt text provided for this image

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

Yasmin agwan

Senior Frontend || JS || React || Redux || Vue.JS || Coder @ CBRE | Mentor | Azure certified | JavaScript Enthusiastic | Mobile App Development

4 年

Great

要查看或添加评论,请登录

Shamsher Alam的更多文章

社区洞察

其他会员也浏览了