Eloquent\Composer\NpmBridge\NpmBridge::isDependantPackage PHP Метод

isDependantPackage() публичный Метод

Returns true if the supplied package requires the Composer NPM bridge.
public isDependantPackage ( Composer\Package\PackageInterface $package, boolean $includeDevDependencies = false ) : boolean
$package Composer\Package\PackageInterface The package to inspect.
$includeDevDependencies boolean True if the dev dependencies should also be inspected.
Результат boolean True if the package requires the bridge.
    public function isDependantPackage(PackageInterface $package, $includeDevDependencies = false)
    {
        foreach ($package->getRequires() as $link) {
            if ('eloquent/composer-npm-bridge' === $link->getTarget()) {
                return true;
            }
        }
        if ($includeDevDependencies) {
            foreach ($package->getDevRequires() as $link) {
                if ('eloquent/composer-npm-bridge' === $link->getTarget()) {
                    return true;
                }
            }
        }
        return false;
    }

Usage Example

 /**
  * Find all NPM bridge enabled vendor packages.
  *
  * @param Composer  $composer The Composer object for the root project.
  * @param NpmBridge $bridge   The bridge to use.
  *
  * @return array<integer,PackageInterface> The list of NPM bridge enabled vendor packages.
  */
 public function find(Composer $composer, NpmBridge $bridge)
 {
     $packages = $composer->getRepositoryManager()->getLocalRepository()->getPackages();
     $dependantPackages = array();
     foreach ($packages as $package) {
         if ($bridge->isDependantPackage($package, false)) {
             $dependantPackages[] = $package;
         }
     }
     return $dependantPackages;
 }