function SiteConfigurationExcluder::syncDefaultSiteDirectoryPermissions
Makes `sites/default` permissions the same in live and stage directories.
Parameters
\Drupal\package_manager\Event\PreApplyEvent $event: The event being handled.
Throws
\Drupal\Core\File\Exception\FileException If the permissions of the live `sites/default` cannot be determined, or cannot be changed on the staged `sites/default`.
File
-
core/
modules/ package_manager/ src/ PathExcluder/ SiteConfigurationExcluder.php, line 98
Class
- SiteConfigurationExcluder
- Excludes site configuration files from stage directories.
Namespace
Drupal\package_manager\PathExcluderCode
public function syncDefaultSiteDirectoryPermissions(PreApplyEvent $event) : void {
$staged_dir = $this->getDefaultSiteDirectoryPath($event->stage
->getStageDirectory());
// If the directory doesn't even exist, there's nothing to do here.
if (!is_dir($staged_dir)) {
return;
}
$live_dir = $this->getDefaultSiteDirectoryPath($this->pathLocator
->getProjectRoot());
$permissions = fileperms($live_dir);
if ($permissions === FALSE) {
throw new FileException("Could not determine permissions for '{$live_dir}'.");
}
if (!$this->fileSystem
->chmod($staged_dir, $permissions)) {
throw new FileException("Could not change permissions on '{$staged_dir}'.");
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.