You are here

protected function ReplaceOp::copyScaffold in Drupal 8

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

Copies 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::copyScaffold()
ReplaceOp::process in composer/Plugin/Scaffold/Operations/ReplaceOp.php
Process this scaffold operation.

File

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

Class

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

Namespace

Drupal\Composer\Plugin\Scaffold\Operations

Code

protected function copyScaffold(ScaffoldFilePath $destination, IOInterface $io) {
  $interpolator = $destination
    ->getInterpolator();
  $this->source
    ->addInterpolationData($interpolator);
  $success = file_put_contents($destination
    ->fullPath(), $this
    ->contents());
  if (!$success) {
    throw new \RuntimeException($interpolator
      ->interpolate("Could not copy source file <info>[src-rel-path]</info> to <info>[dest-rel-path]</info>!"));
  }
  $io
    ->write($interpolator
    ->interpolate("  - Copy <info>[dest-rel-path]</info> from <info>[src-rel-path]</info>"));
  return new ScaffoldResult($destination, $this->overwrite);
}