Score:0

Custom Module Rename

us flag

We have three custom pieces of code for our Drupal website: module, theme and a non-drupal php library. The names of these components have become awkward over time. I would like to rename our custom module from "rsm_library" to "rsm_module".

I created a copy of "rsm_library" on Github as "rsm_module". I then changed all of the internal references from "rsm_library" to "rsm_module". These changes were mostly namespace and use statements. I also made updates to .info and .module. I then used composer to load the new module into the website so that both "rsm_library" and "rsm_module" are available at modules/custom. So far so good.

My next step is to uninstall "rsm_library" using the drupal admin gui. I received a warning message saying the listed configuration will be deleted when I uninstall the module:

  • three custom blocks
  • one REST resource

This seems correct as the support for the blocks/rest is coded in the "rsm_library" module. I looked at the configuration of one of the custom blocks. It contains the following lines -- among others:

dependencies: 
  module:
    - node
    - rsm_library
provider: rsm_library

This is likely the interface between the custom module and the custom block. The REST configuration contains a dependency on "rsm_library" but does not include a provider:.

I am not sure how to proceed to complete the rename of "rsm_library" to "rsm_module". Perhaps something like this:

  • Export the four configurations
  • Change the dependencies/provider from "rsm_library" to "rsm_module"
  • Should I delete the uuid: line?
  • Include the resulting yml in "rsm_module/config/install"

The four configurations will be deleted when I uninstall "rsm_library". They will be included once again when I install "rsm_module". Does this seem to be the correct approach?

Kevin avatar
in flag
I would probably just place 3 new blocks, but this can probably be fixed by changing the dependency names in the config yamls and importing that, then trying to uninstall the old module. Also, probably makes sense to avoid using _library or _module as a naming convention in general.
Score:0
us flag

I proceeded the way I described in the question above -- including deleting the uuid: lines from the yml files. I now have "rsm_library" uninstalled and "rsm_module" installed on the website. The block and rest configurations are in place and seem to be working. I should be able to promote this to our public website with some additional testing.

sonfd avatar
in flag
I don't believe there's any reason to delete the uuid lines.
Kevin avatar
in flag
There isn't, just replacing the dependency lines.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.