getInterpolator example

/** * {@inheritdoc} */
  protected function generateContents() {
    return '';
  }

  /** * {@inheritdoc} */
  public function process(ScaffoldFilePath $destination, IOInterface $io, ScaffoldOptions $options) {
    $interpolator = $destination->getInterpolator();
    $io->write($interpolator->interpolate($this->message));
    return new ScaffoldResult($destination, FALSE);
  }

}


    // Attach it all together.     return $prepend_contents . $original_contents . $append_contents;
  }

  /** * {@inheritdoc} */
  public function process(ScaffoldFilePath $destination, IOInterface $io, ScaffoldOptions $options) {
    $destination_path = $destination->fullPath();
    $interpolator = $destination->getInterpolator();

    // Be extra-noisy of creating a new file or appending to a non-scaffold     // file. Note that if the file already has the append contents, then the     // OperationFactory will make a SkipOp instead, and we will not get here.     if (!$this->managed) {
      $message = ' - <info>NOTICE</info> Modifying existing file at <info>[dest-rel-path]</info>.';
      if (!file_exists($destination_path)) {
        $message = ' - <info>NOTICE</info> Creating a new file at <info>[dest-rel-path]</info>.';
      }
      $message .= ' Examine the contents and ensure that it came out correctly.';
      $io->write($interpolator->interpolate($message));
    }

  public function interpolate($message, array $extra = []$default = FALSE) {
    $interpolator = $this->destination->getInterpolator();
    return $interpolator->interpolate($message$extra$default);
  }

  /** * Moves a single scaffold file from source to destination. * * @param \Composer\IO\IOInterface $io * The scaffold file to be processed. * @param \Drupal\Composer\Plugin\Scaffold\ScaffoldOptions $options * Assorted operational options, e.g. whether the destination should be a * symlink. * * @return \Drupal\Composer\Plugin\Scaffold\Operations\ScaffoldResult * The scaffold result. */


  /** * {@inheritdoc} */
  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);
    }
    
Home | Imprint | This part of the site doesn't use cookies.