FileCopierFactory.php in Automatic Updates 8.2
File
package_manager/src/FileCopierFactory.php
View source
<?php
namespace Drupal\package_manager;
use Drupal\Core\Config\ConfigFactoryInterface;
use PhpTuf\ComposerStager\Infrastructure\Process\FileCopier\FileCopierFactory as StagerFileCopierFactory;
use PhpTuf\ComposerStager\Infrastructure\Process\FileCopier\FileCopierFactoryInterface;
use PhpTuf\ComposerStager\Infrastructure\Process\FileCopier\FileCopierInterface;
use PhpTuf\ComposerStager\Infrastructure\Process\FileCopier\PhpFileCopierInterface;
use PhpTuf\ComposerStager\Infrastructure\Process\FileCopier\RsyncFileCopierInterface;
use Symfony\Component\Process\ExecutableFinder;
class FileCopierFactory implements FileCopierFactoryInterface {
protected $decorated;
protected $phpFileCopier;
protected $rsyncFileCopier;
protected $configFactory;
public function __construct(ExecutableFinder $executable_finder, PhpFileCopierInterface $php_file_copier, RsyncFileCopierInterface $rsync_file_copier, ConfigFactoryInterface $config_factory) {
$this->decorated = new StagerFileCopierFactory($executable_finder, $php_file_copier, $rsync_file_copier);
$this->phpFileCopier = $php_file_copier;
$this->rsyncFileCopier = $rsync_file_copier;
$this->configFactory = $config_factory;
}
public function create() : FileCopierInterface {
$copier = $this->configFactory
->get('package_manager.settings')
->get('file_copier');
switch ($copier) {
case 'rsync':
return $this->rsyncFileCopier;
case 'php':
return $this->phpFileCopier;
default:
return $this->decorated
->create();
}
}
}
Classes
Name |
Description |
FileCopierFactory |
A file copier factory which returns file copiers according to configuration. |