Login

Drupal 7 Dynamic Class Loading

Drupal 7 introduces dynamic class loading. When you package your modules, you need to supply Druapl with a ".info" file. Inside the ".info" file you now declare an array of file listings. Drupal's new Module Registry inventories the file listings and dynamically loads method and objects as needed.

In our example below, we have have a file listing called "my_color_class.inc". The file listing includes several application objects. Before Drupal 7 we would need to use an "include..." statement in any other file listing before we could use those objects.

my_color.info

name = my_color
description = test proof of concept module
package = public-action
version = VERSION
core = 7.x
files[] = my_color.module
files[] = my_color.install
files[] = my_color_class.inc
 
 
; Information added by drupal.org packaging script on 2010-03-21
version = "7.0-alpha3"
project = "drupal"