Cleaner.php in Automatic Updates 8.2
File
src/ComposerStager/Cleaner.php
View source
<?php
namespace Drupal\automatic_updates\ComposerStager;
use Drupal\automatic_updates\PathLocator;
use PhpTuf\ComposerStager\Domain\CleanerInterface;
use PhpTuf\ComposerStager\Domain\Output\ProcessOutputCallbackInterface;
use Symfony\Component\Filesystem\Filesystem;
class Cleaner implements CleanerInterface {
protected $decorated;
protected $sitePath;
protected $pathLocator;
public function __construct(CleanerInterface $decorated, string $site_path, PathLocator $locator) {
$this->decorated = $decorated;
$this->sitePath = $site_path;
$this->pathLocator = $locator;
}
public function clean(string $stagingDir, ?ProcessOutputCallbackInterface $callback = NULL, ?int $timeout = 120) : void {
$site_dir = implode(DIRECTORY_SEPARATOR, [
$stagingDir,
$this->pathLocator
->getWebRoot() ?: '.',
$this->sitePath,
]);
if ($this
->directoryExists($site_dir)) {
(new Filesystem())
->chmod($site_dir, 0777);
}
$this->decorated
->clean($stagingDir, $callback, $timeout);
}
public function directoryExists(string $stagingDir) : bool {
return $this->decorated
->directoryExists($stagingDir);
}
}
Classes
Name |
Description |
Cleaner |
Defines a cleaner service that makes the staged site directory writable. |