public function ModuleUpdater::getInstallDirectory

public ModuleUpdater::getInstallDirectory()

Return the directory where a module should be installed.

If the module is already installed, drupal_get_path() will return a valid path and we should install it there (although we need to use an absolute path, so we prepend DRUPAL_ROOT). If we're installing a new module, we always want it to go into sites/all/modules, since that's where all the documentation recommends users install their modules, and there's no way that can conflict on a multi-site installation, since the Update manager won't let you install a new module if it's already found on your system, and if there was a copy in sites/all, we'd see it.

Overrides DrupalUpdaterInterface::getInstallDirectory

File

modules/system/system.updater.inc, line 26
Subclasses of the Updater class to update Drupal core knows how to update. At this time, only modules and themes are supported.

Class

ModuleUpdater
Class for updating modules using FileTransfer classes via authorize.php.

Code

public function getInstallDirectory() {
  if ($this->isInstalled() && ($relative_path = drupal_get_path('module', $this->name))) {
    $relative_path = dirname($relative_path);
  }
  else {
    $relative_path = 'sites/all/modules';
  }
  return DRUPAL_ROOT . '/' . $relative_path;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!system!system.updater.inc/function/ModuleUpdater::getInstallDirectory/7.x