packageOptions example


  protected function recursiveGetAllowedPackages(array $packages_to_allow, array $allowed_packages = []) {
    foreach ($packages_to_allow as $name) {
      $package = $this->getPackage($name);
      if ($package instanceof PackageInterface && !isset($allowed_packages[$name])) {
        $allowed_packages[$name] = $package;
        $package_options = $this->manageOptions->packageOptions($package);
        $allowed_packages = $this->recursiveGetAllowedPackages($package_options->allowedPackages()$allowed_packages);
      }
    }
    return $allowed_packages;
  }

  /** * Evaluates newly-added packages and see if they are already allowed. * * For now we will only emit warnings if they are not. * * @param array $allowed_packages * Mapping of package names to PackageInterface of packages already * accumulated. * * @return \Composer\Package\PackageInterface[] * Mapping of package names to PackageInterface in priority order. */
/** * Gets the array of file mappings provided by a given package. * * @param \Composer\Package\PackageInterface $package * The Composer package from which to get the file mappings. * * @return \Drupal\Composer\Plugin\Scaffold\Operations\OperationInterface[] * An array of destination paths => scaffold operation objects. */
  protected function getPackageFileMappings(PackageInterface $package) {
    $options = $this->manageOptions->packageOptions($package);
    if ($options->hasFileMapping()) {
      return $this->createScaffoldOperations($package$options->fileMapping());
    }
    // Warn the user if they allow a package that does not have any scaffold     // files. We will ignore drupal/core, though, as it is implicitly allowed,     // but might not have scaffold files (version 8.7.x and earlier).     if (!$options->hasAllowedPackages() && ($package->getName() != 'drupal/core')) {
      $this->io->writeError("The allowed package {$package->getName()} does not provide a file mapping for Composer Scaffold.");
    }
    return [];
  }

  
public function __construct(Composer $composer) {
    $this->composer = $composer;
  }

  /** * Gets the root-level scaffold options for this project. * * @return \Drupal\Composer\Plugin\Scaffold\ScaffoldOptions * The scaffold options object. */
  public function getOptions() {
    return $this->packageOptions($this->composer->getPackage());
  }

  /** * Gets the scaffold options for the stipulated project. * * @param \Composer\Package\PackageInterface $package * The package to fetch the scaffold options from. * * @return \Drupal\Composer\Plugin\Scaffold\ScaffoldOptions * The scaffold options object. */
  
Home | Imprint | This part of the site doesn't use cookies.