public function Module::getInstallDirectory

Returns 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 /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 the top-level we'd see it.

Return value

string A directory path.

Overrides UpdaterInterface::getInstallDirectory

File

drupal/core/lib/Drupal/Core/Updater/Module.php, line 31
Definition of Drupal\Core\Updater\Module.

Class

Module
Defines a class for updating modules using Drupal\Core\FileTransfer\FileTransfer classes via authorize.php.

Namespace

Drupal\Core\Updater

Code

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