You are here

function drupalgap_add_module_to_settings_file in DrupalGap 7.2

Same name and namespace in other branches
  1. 7 drupalgap.module \drupalgap_add_module_to_settings_file()

Given a module name, this will add it to the settings.js file, right after the last module found in the file.

1 call to drupalgap_add_module_to_settings_file()
drupalgap_module_install_form_submit in ./drupalgap.module

File

./drupalgap.module, line 620
A module to provide a bridge between Drupal websites and PhoneGap mobile applications.

Code

function drupalgap_add_module_to_settings_file($module) {
  $modules = drupalgap_load_modules('contrib');
  if ($modules) {

    // A module(s) is installed, append this module after the last module.
    $look_for = $modules[0][sizeof($modules[0]) - 1];
  }
  else {

    // No modules are installed yet, add this module right after the module
    // comments. This is a terrible assumption, but we'll use it until we don't
    // have the settings scattered throughout a JS file like a dumb dumb.
    $look_for = '/** Contributed Modules - www/app/modules **/';
  }
  file_put_contents(drupalgap_path_to_settings_file(), str_replace($look_for, $look_for . "\nDrupal.modules.contrib['{$module}'] = {};", drupalgap_load_settings_as_string()));
}