本文整理匯總了PHP中Composer\Repository\RepositoryInterface::hadInvalidBranches方法的典型用法代碼示例。如果您正苦於以下問題:PHP RepositoryInterface::hadInvalidBranches方法的具體用法?PHP RepositoryInterface::hadInvalidBranches怎麽用?PHP RepositoryInterface::hadInvalidBranches使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Composer\Repository\RepositoryInterface
的用法示例。
在下文中一共展示了RepositoryInterface::hadInvalidBranches方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: update
/**
* Update a project
*
* @param \Packagist\WebBundle\Entity\Package $package
* @param RepositoryInterface $repository the repository instance used to update from
* @param int $flags a few of the constants of this class
* @param \DateTime $start
*/
public function update(Package $package, RepositoryInterface $repository, $flags = 0, \DateTime $start = null)
{
$blacklist = '{^symfony/symfony (2.0.[456]|dev-charset|dev-console)}i';
if (null === $start) {
$start = new \DateTime();
}
$pruneDate = clone $start;
$pruneDate->modify('-8days');
$versions = $repository->getPackages();
$em = $this->doctrine->getManager();
if ($repository->hadInvalidBranches()) {
throw new InvalidRepositoryException('Some branches contained invalid data and were discarded, it is advised to review the log and fix any issues present in branches');
}
usort($versions, function ($a, $b) {
$aVersion = $a->getVersion();
$bVersion = $b->getVersion();
if ($aVersion === '9999999-dev' || 'dev-' === substr($aVersion, 0, 4)) {
$aVersion = 'dev';
}
if ($bVersion === '9999999-dev' || 'dev-' === substr($bVersion, 0, 4)) {
$bVersion = 'dev';
}
if ($aVersion === $bVersion) {
return $a->getReleaseDate() > $b->getReleaseDate() ? 1 : -1;
}
return version_compare($a->getVersion(), $b->getVersion());
});
$versionRepository = $this->doctrine->getRepository('PackagistWebBundle:Version');
if ($flags & self::DELETE_BEFORE) {
foreach ($package->getVersions() as $version) {
$versionRepository->remove($version);
}
$em->flush();
$em->refresh($package);
}
foreach ($versions as $version) {
if ($version instanceof AliasPackage) {
continue;
}
if (preg_match($blacklist, $version->getName() . ' ' . $version->getPrettyVersion())) {
continue;
}
$this->updateInformation($package, $version, $flags);
$em->flush();
}
// remove outdated versions
foreach ($package->getVersions() as $version) {
if ($version->getUpdatedAt() < $pruneDate) {
$versionRepository->remove($version);
}
}
$package->setUpdatedAt(new \DateTime());
$package->setCrawledAt(new \DateTime());
$em->flush();
}
示例2: update
/**
* Update a project
*
* @param \Packagist\WebBundle\Entity\Package $package
* @param RepositoryInterface $repository the repository instance used to update from
* @param int $flags a few of the constants of this class
* @param \DateTime $start
*/
public function update(IOInterface $io, Config $config, Package $package, RepositoryInterface $repository, $flags = 0, \DateTime $start = null)
{
$rfs = new RemoteFilesystem($io, $config);
$blacklist = '{^symfony/symfony (2.0.[456]|dev-charset|dev-console)}i';
if (null === $start) {
$start = new \DateTime();
}
$pruneDate = clone $start;
$pruneDate->modify('-1min');
$versions = $repository->getPackages();
$em = $this->doctrine->getManager();
usort($versions, function ($a, $b) {
$aVersion = $a->getVersion();
$bVersion = $b->getVersion();
if ($aVersion === '9999999-dev' || 'dev-' === substr($aVersion, 0, 4)) {
$aVersion = 'dev';
}
if ($bVersion === '9999999-dev' || 'dev-' === substr($bVersion, 0, 4)) {
$bVersion = 'dev';
}
$aIsDev = $aVersion === 'dev' || substr($aVersion, -4) === '-dev';
$bIsDev = $bVersion === 'dev' || substr($bVersion, -4) === '-dev';
// push dev versions to the end
if ($aIsDev !== $bIsDev) {
return $aIsDev ? 1 : -1;
}
// equal versions are sorted by date
if ($aVersion === $bVersion) {
return $a->getReleaseDate() > $b->getReleaseDate() ? 1 : -1;
}
// the rest is sorted by version
return version_compare($aVersion, $bVersion);
});
$versionRepository = $this->doctrine->getRepository('PackagistWebBundle:Version');
if ($flags & self::DELETE_BEFORE) {
foreach ($package->getVersions() as $version) {
$versionRepository->remove($version);
}
$em->flush();
$em->refresh($package);
}
$lastUpdated = true;
foreach ($versions as $version) {
if ($version instanceof AliasPackage) {
continue;
}
if (preg_match($blacklist, $version->getName() . ' ' . $version->getPrettyVersion())) {
continue;
}
$lastUpdated = $this->updateInformation($package, $version, $flags);
if ($lastUpdated) {
$em->flush();
}
}
if (!$lastUpdated) {
$em->flush();
}
// remove outdated versions
foreach ($package->getVersions() as $version) {
if ($version->getUpdatedAt() < $pruneDate) {
$versionRepository->remove($version);
}
}
if (preg_match('{^(?:git://|git@|https?://)github.com[:/]([^/]+)/(.+?)(?:\\.git|/)?$}i', $package->getRepository(), $match)) {
$this->updateGitHubInfo($rfs, $package, $match[1], $match[2]);
}
$package->setUpdatedAt(new \DateTime());
$package->setCrawledAt(new \DateTime());
$em->flush();
if ($repository->hadInvalidBranches()) {
throw new InvalidRepositoryException('Some branches contained invalid data and were discarded, it is advised to review the log and fix any issues present in branches');
}
}