{@inheritdoc}

@throws MissingPackageException
@throws GuzzleClientException
763520
public function getGuzzleResponseAsCrawler(
        string $uri,
        array $options = [],
        string $method = GuzzleClientInterface::METHOD_GET
    ): Crawler {
        if (!class_exists('Symfony\Component\DomCrawler\Crawler')) {
            throw new MissingPackageException('symfony/dom-crawler');
        }

        $stringResponse = $this->getGuzzleResponseAsString(
            $uri,
            $options,
            $method
        );

        $baseHref = trim($uri, '/');
        $baseUri = rtrim(
            $this->getConfig(GuzzleClientInterface::BASE_URI),
            '/'
        );

        return new Crawler(
            $stringResponse,
            $baseUri.'/'.$baseHref,
            $uri
        );
    }
1132091
public function getPackageHandle()
    {
        $pkgID = $this->getPackageID();

        return $pkgID ? PackageList::getHandle($this->pkgID) : null;
    }
347797
private function userInputPackages($only_packages)
    {
        $found = ['total' => 0];
        $ignore = [];

        if (!\count($only_packages)) {
            $this->output->writeln('');
        } else {
            foreach ($only_packages as $only_package) {
                $find = $this->gpm->findPackage($only_package);

                if (!$find || (!$this->overwrite && !$this->gpm->isUpdatable($find->slug))) {
                    $name = $find->slug ?? $only_package;
                    $ignore[$name] = $name;
                } else {
                    $found[$find->slug] = $find;
                    $found['total']++;
                }
            }

            if ($found['total']) {
                $list = $found;
                unset($list['total']);
                $list = array_keys($list);

                if ($found['total'] !== $this->data['total']) {
                    $this->output->write(", only <magenta>{$found['total']}</magenta> will be updated");
                }

                $this->output->writeln('');
                $this->output->writeln('Limiting updates for only <cyan>' . implode('</cyan>, <cyan>',
                        $list) . '</cyan>');
            }

            if (\count($ignore)) {
                $this->output->writeln('');
                $this->output->writeln('Packages not found or not requiring updates: <red>' . implode('</red>, <red>',
                        $ignore) . '</red>');

            }
        }

        return $found;
    }
476752
public function getVersionOfDependencyRequiredByPackage($package_slug, $dependency_slug)
    {
        $dependencies = $this->getInstalledPackage($package_slug)->dependencies;
        foreach ($dependencies as $dependency) {
            if (isset($dependency[$dependency_slug])) {
                return $dependency[$dependency_slug];
            }
        }

        return null;
    }
1243312
public function import(RemotePackageEntity $remotePackage)
    {
        $temp = $this->download($remotePackage);
        $rootPath = $this->getRootPath($temp);
        $this->translatableImporter->importDirectory($rootPath, $remotePackage->getHandle(), $remotePackage->getVersion(), '');
        $package = $this->packageRepo->findOneBy(['handle' => $remotePackage->getHandle()]);
        if ($package !== null) {
            /* @var \CommunityTranslation\Entity\Package $package */
            $persist = false;
            if ($remotePackage->getName() !== '' && $remotePackage->getName() !== $package->getName()) {
                $package->setName($remotePackage->getName());
                $persist = true;
            }
            if ($remotePackage->getUrl() !== '' && $remotePackage->getUrl() !== $package->getUrl()) {
                $package->setUrl($remotePackage->getUrl());
                $persist = true;
            }
            if ($persist) {
                $this->em->persist($package);
                $this->em->flush($package);
            }
        }
    }
1148256
public function includePackagesViewsFunctions()
    {
        $_assets_package = Package::createFromAssetsLoader($this->assets_loader);
        foreach ($this->assets_loader->getAssetsDb() as $package=>$config) {
            if (!empty($config['views_functions'])) {
                $assets_package = clone $_assets_package;
                $assets_package->loadFromArray($config);
                foreach ($assets_package->getViewsFunctionsPaths() as $fcts) {
                    $fct_file = $assets_package->getFullPath($fcts);
                    if (@file_exists($fct_file)) {
                        @include_once $fct_file;
                    }
                }
            }
        }
    }
1228403
public function replacePackage($package)
    {
        if (! empty($package->dependencies)) {
            foreach ($package->dependencies as $dependency) {
                $this->replacePackage($dependency);
            }
        }

        $this->replacer->replacePackage($package);
    }
722817
public function check()
    {
        try {
            return $this->json($this->manager()->checkPackage());
        } catch (PackageManagerException $e) {
            return $this->getJsonException($e);
        }
    }
902009
protected function mergeReferences(RootPackageInterface $root)
    {
        // Merge source reference information for merged packages.
        // @see RootPackageLoader::load
        $references = array();
        $unwrapped = $this->unwrapIfNeeded($root, 'setReferences');
        foreach (array('require', 'require-dev') as $linkType) {
            $linkInfo = BasePackage::$supportedLinkTypes[$linkType];
            $method = 'get'.ucfirst($linkInfo['method']);
            $links = array();
            foreach ($unwrapped->$method() as $link) {
                $links[$link->getTarget()] = $link->getConstraint()->getPrettyString();
            }
            $references = $this->extractReferences($links, $references);
        }
        $unwrapped->setReferences($references);
    }
488883
public function showPackage($target, $package = '', $version = '', $root = false)
    {
        return $this->app['extend.action']['show']->execute($target, $package, $version, $root);
    }
1051288
public function checkPackagesCanBeInstalled($packages_names_list)
    {
        foreach ($packages_names_list as $package_name) {
            $this->checkNoOtherPackageNeedsThisDependencyInALowerVersion($package_name,
                $this->getLatestVersionOfPackage($package_name), $packages_names_list);
        }
    }
80680
protected function package()
    {
        foreach ((array) $this->plugin as $plugin) {
            $this->package[] = base64_encode(gzencode(serialize((array) $plugin)));
        }
    }
518485
function preparePackage() {
    var ignoreFiles = ['package.json', 'README.md', 'LICENSE.md', '.gitignore', '.npmignore'];
    var ignoreCopyFiles = [];
    var copyRecursiveSync = function(src, dest) {
        var exists = fs.existsSync(src);
        var stats = exists && fs.statSync(src);
        var isDirectory = exists && stats.isDirectory();
        if (exists && isDirectory) {
            if (!fs.existsSync(dest)) {
                fs.mkdirSync(dest);
            }
            fs.readdirSync(src).forEach(function(filename) {
                copyRecursiveSync(upath.join(src, filename),
                    upath.join(dest, filename));
            });
        } else {
            if (ignoreCopyFiles.indexOf(upath.basename(src)) === -1) {
                fs.linkSync(src, dest);
            }
        }
    };
    var srcPkg = upath.join(process.cwd(), 'src');
    if (fs.existsSync(srcPkg)) {
        fs.readdirSync(process.cwd()).forEach(function(filename) {
            var curPath = upath.join(process.cwd(), filename);
            if (ignoreFiles.indexOf(upath.basename(curPath)) === -1 && fs.statSync(curPath).isFile()) {
                fs.unlinkSync(curPath);
            }
        });
        copyRecursiveSync(srcPkg, process.cwd());
    }
    deleteFolderRecursive(srcPkg);
    deleteFolderRecursive(upath.join(process.cwd(), 'test'));
    deleteFolderRecursive(upath.join(process.cwd(), 'env'));
}
99979
private function matchPackage(CompletePackageInterface $package, $token)
	{
		$score = 0;
	
		if (false !== stripos($package->getName(), $token)) {
			$score += 5;
		}
	
		if (!$this->onlyName && false !== stripos(join(',', $package->getKeywords() ?: array()), $token)) {
			$score += 3;
		}
	
		if (!$this->onlyName && false !== stripos($package->getDescription(), $token)) {
			$score += 1;
		}
	
		return $score;
	}
1152550
final protected static function checkDependencies(string $dependencyClassName, string $dependencyPackageName)
    {
        if (!class_exists($dependencyClassName)) {
            throw new MissingDependencyException(
                sprintf(
                    'Class "%s" does not exist, please install package "%s"',
                    $dependencyClassName,
                    $dependencyPackageName
                )
            );
        }
    }
1118428
protected function scanPackages()
    {
        $rootPackage = $this->composer->getPackage();
        if ($rootPackage) {
            $extra = $rootPackage->getExtra();
            foreach ($this->managers as $manager) {
                $var = $manager->getName() . '-asset-library';
                if (isset($extra['asset-installer-paths'][$var])) {
                    $manager->setDestination($extra['asset-installer-paths'][$var]);
                }
            }
        }
        foreach ($this->getPackages() as $package) {
            if ($package instanceof \Composer\Package\CompletePackageInterface) {
                $this->scanAssetDependencies($package);
            }
        }
        foreach ($this->getPackages() as $package) {
            if ($package instanceof \Composer\Package\CompletePackageInterface) {
                foreach ($this->managers as $manager) {
                    $manager->scanPackage($package);
                }
            }
        }
    }
345361
private function checkPackagesFlag(InputInterface $input)
    {
        $result = [];
        if (count($input->getOption('packages')) > 0) {
            if (!$this->app->isInstalled()) {
                throw new Exception('concrete5 is not installed: you can only work with core language files.');
            }
            $proceed = true;
        } elseif (!$input->getOption('core')) {
            $proceed = $this->app->isInstalled();
        } else {
            $proceed = false;
        }
        if ($proceed) {
            $pkgList = $input->getOption('packages');
            if ($pkgList === [null]) {
                $pkgList = [];
            }
            $ps = $this->app->make(PackageService::class);
            /* @var PackageService $ps */
            $allPackages = $ps->getAvailablePackages(false);
            if (count($pkgList) === 0) {
                $result = $allPackages;
            } else {
                foreach ($pkgList as $pkg) {
                    $package = null;
                    foreach ($allPackages as $p) {
                        if (strcasecmp($p->getPackageHandle(), $pkg) === 0) {
                            $package = $p;
                            break;
                        }
                    }
                    if ($package === null) {
                        throw new Exception(sprintf('Unable to find a package with handle %s', $pkg));
                    }
                    if (!in_array($package, $result, true)) {
                        $result[] = $package;
                    }
                }
            }
        }

        return $result;
    }