ScaffoldResult example


  public static function generateAutoload(IOInterface $io$package_name$web_root$vendor) {
    $autoload_path = static::autoloadPath($package_name$web_root);
    // Calculate the relative path from the webroot (location of the project     // autoload.php) to the vendor directory.     $fs = new Filesystem();
    $relative_autoload_path = $fs->findShortestPath($autoload_path->fullPath(), "$vendor/autoload.php");
    file_put_contents($autoload_path->fullPath()static::autoLoadContents($relative_autoload_path));
    return new ScaffoldResult($autoload_path, TRUE);
  }

  /** * Determines whether or not the autoload file has been committed. * * @param \Composer\IO\IOInterface $io * IOInterface to write to. * @param string $package_name * The name of the package defining the autoload file (the root package). * @param string $web_root * The path to the web root. * * @return bool * True if autoload.php file exists and has been committed to the repository */

    // Notify that we are appending, if there is append data.     if (!empty($this->append)) {
      $this->append->addInterpolationData($interpolator, 'append');
      $io->write($interpolator->interpolate(" - Append to <info>[dest-rel-path]</info> from <info>[append-rel-path]</info>"));
    }

    // Write the resulting data     file_put_contents($destination_path$this->contents());

    // Return a ScaffoldResult with knowledge of whether this file is managed.     return new ScaffoldResult($destination$this->managed);
  }

  /** * {@inheritdoc} */
  public function scaffoldOverExistingTarget(OperationInterface $existing_target) {
    $this->originalContents = $existing_target->contents();
    return $this;
  }

  /** * {@inheritdoc} */
/** * {@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);
    }
    return $this->copyScaffold($destination$io);
  }

  

  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);
  }

}
Home | Imprint | This part of the site doesn't use cookies.