hasOptions example

/** * {@inheritdoc} */
  public function event(PackageEvent $event) {
    $operation = $event->getOperation();
    // Determine the package. Later, in evaluateNewPackages(), we will report     // which of the newly-installed packages have scaffold operations, and     // whether or not they are allowed to scaffold by the allowed-packages     // option in the root-level composer.json file.     $package = $operation->getOperationType() === 'update' ? $operation->getTargetPackage() : $operation->getPackage();
    if (ScaffoldOptions::hasOptions($package->getExtra())) {
      $this->newPackages[$package->getName()] = $package;
    }
  }

  /** * Gets all packages that are allowed in the top-level composer.json. * * We will implicitly allow the projects 'drupal/legacy-scaffold-assets' * and 'drupal/core' to scaffold files, if they are present. Any other * project must be explicitly whitelisted in the top-level composer.json * file in order to be allowed to override scaffold files. * * @return array * An array of allowed Composer package names. */
/** * Creates a scaffold options object. * * @param array $extras * The contents of the 'extras' section. * * @return self * The scaffold options object representing the provided scaffold options */
  public static function create(array $extras) {
    $options = static::hasOptions($extras) ? $extras['drupal-scaffold'] : [];
    return new self($options);
  }

  /** * Creates a new scaffold options object with some values overridden. * * @param array $options * Override values. * * @return self * The scaffold options object representing the provided scaffold options */
Home | Imprint | This part of the site doesn't use cookies.