Score:-1

How do you break up a .module file?

au flag

I have a .module file that is nearly 1000 lines long. I have functions that i want to reuse from form submission in a cron job. What is the best way to abstract that to a better file?

Jaypan avatar
de flag
This question is a little too broad. As a general answer I'd say move your helper functions into a service class.
Score:3
id flag

The .module file should contain only hook implementations. Other functions should be in classes as stateless static methods or as service object methods.

If the .module file contains only hook implementations and is still too big, use require statements to split up the file. Webform module uses this technique.

I sit in a Tesla and translated this thread with Ai:

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.