function UpdateRoot::__toString
Same name in other branches
- 10 core/modules/update/src/UpdateRoot.php \Drupal\update\UpdateRoot::__toString()
- 11.x core/modules/update/src/UpdateRoot.php \Drupal\update\UpdateRoot::__toString()
Gets the root path under which projects are installed or updated.
The Update Manager will ensure that project files can only be copied to specific subdirectories of this root path.
Return value
string
File
-
core/
modules/ update/ src/ UpdateRoot.php, line 65
Class
- UpdateRoot
- Gets the root path used by the Update Manager to install or update projects.
Namespace
Drupal\updateCode
public function __toString() : string {
// Return the $updateRoot when it is set.
if (isset($this->updateRoot)) {
return $this->updateRoot;
}
// Normally the Update Manager's root path is the same as the app root (the
// directory in which the Drupal site is installed).
$root_path = $this->drupalKernel
->getAppRoot();
// When running in a test site, change the root path to be the testing site
// directory. This ensures that it will always be writable by the webserver
// (thereby allowing the actual extraction and installation of projects by
// the Update Manager to be tested) and also ensures that new project files
// added there won't be visible to the parent site and will be properly
// cleaned up once the test finishes running. This is done here (rather
// than having the tests enable a module which overrides the update root
// factory service) to ensure that the parent site is automatically kept
// clean without relying on test authors to take any explicit steps. See
// also \Drupal\update\Tests\Functional\UpdateTestBase::setUp().
if (DRUPAL_TEST_IN_CHILD_SITE) {
$kernel = $this->drupalKernel;
$request = $this->requestStack
->getCurrentRequest();
$root_path .= '/' . $kernel::findSitePath($request);
}
return $root_path;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.