You are here

function include_set_root in Include 8

Same name and namespace in other branches
  1. 6 include.module \include_set_root()
  2. 7 include.module \include_set_root()

Appends the include files repository to the include_path.

This function should only be called when a file in the repository is needed, and cannot be found in the regular include_path. This sets the 'include_set_root' variable to TRUE, which ensures that this function runs again on every non-cached page request.

See also

include_init()

2 calls to include_set_root()
include_check_path in ./include.module
Verifies or installs a file or directory into the include repository.
include_init in ./include.module
Implements hook_init().
3 string references to 'include_set_root'
include_clear_root in ./include.module
Clear the include files repository from the include_path.
include_disable in ./include.install
Implements hook_disable().
include_init in ./include.module
Implements hook_init().

File

./include.module, line 41
The Include module manages files on the include_files path.

Code

function include_set_root() {
  static $done = FALSE;
  if ($done || cache_get('include_error', 'cache_menu')) {
    return;
  }
  if (!variable_get('include_set_root', FALSE)) {
    watchdog('include', 'Adding directory: %path to include path.', array(
      '%path' => include_get_root(),
    ), WATCHDOG_NOTICE);

    // Setting the include_set_root variable ensures that the include_path gets
    // set in the include_init() function.
    variable_set('include_set_root', $done = TRUE);
  }
  set_include_path(implode(PATH_SEPARATOR, array_unique(array_merge(explode(PATH_SEPARATOR, get_include_path()), array(
    include_get_root(),
  )))));
}