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. |
return | 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;
}
/** * 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; }