hasFileMapping example


  public function getAllowedPackages() {
    $top_level_packages = $this->getTopLevelAllowedPackages();
    $allowed_packages = $this->recursiveGetAllowedPackages($top_level_packages);
    // If the root package defines any file mappings, then implicitly add it     // to the list of allowed packages. Add it at the end so that it overrides     // all the preceding packages.     if ($this->manageOptions->getOptions()->hasFileMapping()) {
      $root_package = $this->composer->getPackage();
      unset($allowed_packages[$root_package->getName()]);
      $allowed_packages[$root_package->getName()] = $root_package;
    }
    // Handle any newly-added packages that are not already allowed.     return $this->evaluateNewPackages($allowed_packages);
  }

  /** * {@inheritdoc} */
  
/** * 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 [];
  }

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