Skip to main content
Improved formatting
Source Link
Kwadz
  • 489
  • 9
  • 18

I'd like to execute PHP code that requires functions available in the includes files of core located in core/includes.

I found ModuleHandler()->loadInclude()ModuleHandler()->loadInclude() and module_load_include()module_load_include() but I am afraid this 2 options can load files from core/modules directory only, according to the doc, but may be I misinterpreted it:

Loads a module include file.

For example if I execute:

\Drupal::moduleHandler()->loadInclude('core', 'inc', 'install');
drupal_rewrite_settings(); // the func that I want located in install.inc

I get:

Call to undefined function drupal_rewrite_settings()

which means install.inc has not been loaded.

I'd like to execute PHP code that requires functions available in the includes files of core located in core/includes.

I found ModuleHandler()->loadInclude() and module_load_include() but I am afraid this 2 options can load files from core/modules directory only, according to the doc, but may be I misinterpreted it:

Loads a module include file.

For example if I execute:

\Drupal::moduleHandler()->loadInclude('core', 'inc', 'install');
drupal_rewrite_settings(); // the func that I want located in install.inc

I get:

Call to undefined function drupal_rewrite_settings()

which means install.inc has not been loaded.

I'd like to execute PHP code that requires functions available in the includes files of core located in core/includes.

I found ModuleHandler()->loadInclude() and module_load_include() but I am afraid this 2 options can load files from core/modules directory only, according to the doc, but may be I misinterpreted it:

Loads a module include file.

For example if I execute:

\Drupal::moduleHandler()->loadInclude('core', 'inc', 'install');
drupal_rewrite_settings(); // the func that I want located in install.inc

I get:

Call to undefined function drupal_rewrite_settings()

which means install.inc has not been loaded.

Source Link
Kwadz
  • 489
  • 9
  • 18

How to load a file located in core/includes?

I'd like to execute PHP code that requires functions available in the includes files of core located in core/includes.

I found ModuleHandler()->loadInclude() and module_load_include() but I am afraid this 2 options can load files from core/modules directory only, according to the doc, but may be I misinterpreted it:

Loads a module include file.

For example if I execute:

\Drupal::moduleHandler()->loadInclude('core', 'inc', 'install');
drupal_rewrite_settings(); // the func that I want located in install.inc

I get:

Call to undefined function drupal_rewrite_settings()

which means install.inc has not been loaded.