You are here

protected function ReplaceOp::symlinkScaffold in Drupal 10

Same name and namespace in other branches
  1. 8 composer/Plugin/Scaffold/Operations/ReplaceOp.php \Drupal\Composer\Plugin\Scaffold\Operations\ReplaceOp::symlinkScaffold()
  2. 9 composer/Plugin/Scaffold/Operations/ReplaceOp.php \Drupal\Composer\Plugin\Scaffold\Operations\ReplaceOp::symlinkScaffold()

Symlinks the scaffold file.

Parameters

\Drupal\Composer\Plugin\Scaffold\ScaffoldFilePath $destination: Scaffold file to process.

\Composer\IO\IOInterface $io: IOInterface to writing to.

Return value

\Drupal\Composer\Plugin\Scaffold\Operations\ScaffoldResult The scaffold result.

1 call to ReplaceOp::symlinkScaffold()
ReplaceOp::process in composer/Plugin/Scaffold/Operations/ReplaceOp.php
Process this scaffold operation.

File

composer/Plugin/Scaffold/Operations/ReplaceOp.php, line 113

Class

ReplaceOp
Scaffold operation to copy or symlink from source to destination.

Namespace

Drupal\Composer\Plugin\Scaffold\Operations

Code

protected function symlinkScaffold(ScaffoldFilePath $destination, IOInterface $io) {
  $interpolator = $destination
    ->getInterpolator();
  try {
    $fs = new Filesystem();
    $fs
      ->relativeSymlink($this->source
      ->fullPath(), $destination
      ->fullPath());
  } catch (\Exception $e) {
    throw new \RuntimeException($interpolator
      ->interpolate("Could not symlink source file <info>[src-rel-path]</info> to <info>[dest-rel-path]</info>!"), [], $e);
  }
  $io
    ->write($interpolator
    ->interpolate("  - Link <info>[dest-rel-path]</info> from <info>[src-rel-path]</info>"));
  return new ScaffoldResult($destination, $this->overwrite);
}