Why am I urged to include my source files via files[] instead of using include_once?

drupal.stackexchange https://drupal.stackexchange.com/questions/11878

  •  16-10-2019
  •  | 
  •  

문제

What is the reason of using the .info file to declare the files used from the module, instead of including them at runtime?

도움이 되었습니까?

해결책

From Writing .info files (Drupal 7.x):

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 (...). When a module is enabled, Drupal will rescan all declared files and index all the classes and interfaces that it finds. Classes will be loaded automatically by PHP when they are first accessed.

So it only makes sense to add a file to the files[] array, if that file contains declarations of classes or interfaces and is not included manually (e.g. by calling module_load_include()).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 drupal.stackexchange
scroll top