I have a module that demonstrates how to use another module (a graphing library). One of my controllers uses a large dataset to generate one of the example graphs. I currently have this data assigned to a variable in the controller. However, this takes up a large amount of space in the file. If I want to meet Drupal code style guidelines, I would have to break up the array after every [x,y] pair, making it even more difficult to review.

Should I move this data into some sort of include file, and read the text file into my controller? What's the "Drupal Way"?

1 Answer 1


Your intuition is correct; you should break out your large dataset into some include file. I don't believe there's a strict mention of large datasets in the Drupal coding standards, but isolating out large datasets is good way to isolate concerns (i.e. code-readability vs. dataset referencing).

A good reference example of this would be the Transliteration module. It has a transliteration dataset of include files indexed by unicode byte that's loaded on demand as it needs to transliterate a unicode characters to ASCII.

Your data will obviously be structured to fit your own use case, but given you're probably not the first person to work with large graphic library datasets and PHP, there's probably some general practices to glean from others who've worked on the same problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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