Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the purpose of files[] in .info?

I've just started learning discovering the changes to Drupal 7, and I just found the files[] array now required in the mymodule.info. From what I've found, it is required to add the mymodule.module file to the list, but what other uses does it have?

From what I've read I figured I should be able to separate my code into several files, for example I wanted to make a mymodule.blocks.inc to contain all the code for my blocks, but it seems like the mymodule_block_info() function never runs.

Am I doing something wrong, or is this not how it is supposed to be used?

like image 810
Marco Avatar asked Dec 02 '25 16:12

Marco


1 Answers

As the documentation says:

files (Optional) Drupal now supports a dynamic-loading code registry. To support it, all modules must now declare any code files containing class or interface declarations in the .info file.

This is only used if the file you specify in files[] contains a class or an interface. If so, the file will be auto-loaded only when needed.
No other files should be declared using files[].

like image 134
Haza Avatar answered Dec 05 '25 18:12

Haza



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!