1

I'm using module to create content types and views I need.

  • I prepare the content type in admin, then use export to export the configuration (i.e. views.view.my_view_name.yml, etc).
  • Then I copy relevant pieces of configuration to the mymodule/config/install directory.
  • I installed the module and it added the content type.

Now I had to update the content type's field display.

  • So I changed it in admin and exported.
  • Copied the updated file to my module.

Now I need to let Drupal know that my module is changed and to "reload" it.

  • Clearing cache did not help.
  • Calling /update.php said "nothing to update".
  • Only thing that actually worked is disable/re-enable the the module. But in that process it breaks all the nodes that used the content type in the module (because for some time the content type was unavailable and therefore it "downgraded" it to normal node).

What is a standard way to develop modules? Removing the module after every change seems ridiculous.

  • Just a note that configuration under /install is only set on disable and enable. There is supposedly a drush command to reload this into active config without doing that, but I have not been able to get it to work. – Kevin Oct 3 '16 at 17:14
2

I think this post may be helpful to you:

https://www.mediacurrent.com/blog/registering-migrations-drupal-8

When developing migration configs, you need to update the configs, and it's difficult to get the changes within the install folder to re-register, so there are some scripts you can use, and there are some example drush commands.

Basically you can edit the configs with

$editable = \Drupal::configFactory()->getEditable($config_name);

And you can reinstall configs with

\Drupal::service('config.installer')->installDefaultConfig('module', $module_name);

I'd take a look at the code in /core/lib/Drupal/Core/Config/ConfigInstaller.php in the installDefaultConfig function. You could probably use part of that code to update just the config you need to update without touching the parts that should stay the same.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.