public function ReplaceOp::process in Drupal 10
Same name and namespace in other branches
- 8 composer/Plugin/Scaffold/Operations/ReplaceOp.php \Drupal\Composer\Plugin\Scaffold\Operations\ReplaceOp::process()
- 9 composer/Plugin/Scaffold/Operations/ReplaceOp.php \Drupal\Composer\Plugin\Scaffold\Operations\ReplaceOp::process()
Process this scaffold operation.
Parameters
\Drupal\Composer\Plugin\Scaffold\ScaffoldFilePath $destination: Scaffold file's destination path.
\Composer\IO\IOInterface $io: IOInterface to write to.
\Drupal\Composer\Plugin\Scaffold\ScaffoldOptions $options: Various options that may alter the behavior of the operation.
Return value
\Drupal\Composer\Plugin\Scaffold\Operations\ScaffoldResult Result of the scaffolding operation.
Overrides OperationInterface::process
File
- composer/
Plugin/ Scaffold/ Operations/ ReplaceOp.php, line 60
Class
- ReplaceOp
- Scaffold operation to copy or symlink from source to destination.
Namespace
Drupal\Composer\Plugin\Scaffold\OperationsCode
public function process(ScaffoldFilePath $destination, IOInterface $io, ScaffoldOptions $options) {
$fs = new Filesystem();
$destination_path = $destination
->fullPath();
// Do nothing if overwrite is 'false' and a file already exists at the
// destination.
if ($this->overwrite === FALSE && file_exists($destination_path)) {
$interpolator = $destination
->getInterpolator();
$io
->write($interpolator
->interpolate(" - Skip <info>[dest-rel-path]</info> because it already exists and overwrite is <comment>false</comment>."));
return new ScaffoldResult($destination, FALSE);
}
// Get rid of the destination if it exists, and make sure that
// the directory where it's going to be placed exists.
$fs
->remove($destination_path);
$fs
->ensureDirectoryExists(dirname($destination_path));
if ($options
->symlink()) {
return $this
->symlinkScaffold($destination, $io);
}
return $this
->copyScaffold($destination, $io);
}