function Theme::getInstallDirectory
Same name in other branches
- 9 core/lib/Drupal/Core/Updater/Theme.php \Drupal\Core\Updater\Theme::getInstallDirectory()
- 8.9.x core/lib/Drupal/Core/Updater/Theme.php \Drupal\Core\Updater\Theme::getInstallDirectory()
- 10 core/lib/Drupal/Core/Updater/Theme.php \Drupal\Core\Updater\Theme::getInstallDirectory()
Returns the directory where a theme should be installed.
If the theme is already installed, \Drupal::service('extension.list.theme')->getPath() will return a valid path and we should install it there. If we're installing a new theme, we always want it to go into /themes, since that's where all the documentation recommends users install their themes, and there's no way that can conflict on a multi-site installation, since the Update manager won't let you install a new theme 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 The absolute path of the directory.
Overrides Updater::getInstallDirectory
File
-
core/
lib/ Drupal/ Core/ Updater/ Theme.php, line 27
Class
- Theme
- Defines a class for updating themes.
Namespace
Drupal\Core\UpdaterCode
public function getInstallDirectory() {
if ($this->isInstalled() && ($relative_path = \Drupal::service('extension.list.theme')->getPath($this->name))) {
// The return value of
// \Drupal::service('extension.list.theme')->getPath() is always relative
// to the site, so prepend DRUPAL_ROOT.
return DRUPAL_ROOT . '/' . dirname($relative_path);
}
else {
// When installing a new theme, prepend the requested root directory.
return $this->root . '/' . $this->getRootDirectoryRelativePath();
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.