本文整理汇总了PHP中Composer\Package\PackageInterface::getSuggests方法的典型用法代码示例。如果您正苦于以下问题:PHP PackageInterface::getSuggests方法的具体用法?PHP PackageInterface::getSuggests怎么用?PHP PackageInterface::getSuggests使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Composer\Package\PackageInterface
的用法示例。
在下文中一共展示了PackageInterface::getSuggests方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addSuggestionsFromPackage
/**
* Add all suggestions from a package.
*
* @param PackageInterface $package
* @return SuggestedPackagesReporter
*/
public function addSuggestionsFromPackage(PackageInterface $package)
{
$source = $package->getPrettyName();
foreach ($package->getSuggests() as $target => $reason) {
$this->addPackage($source, $target, $reason);
}
return $this;
}
示例2: dump
public function dump(PackageInterface $package)
{
$keys = array('binaries' => 'bin', 'type', 'extra', 'installationSource' => 'installation-source', 'autoload', 'notificationUrl' => 'notification-url', 'includePaths' => 'include-path');
$data = array();
$data['name'] = $package->getPrettyName();
$data['version'] = $package->getPrettyVersion();
$data['version_normalized'] = $package->getVersion();
if ($package->getTargetDir()) {
$data['target-dir'] = $package->getTargetDir();
}
if ($package->getSourceType()) {
$data['source']['type'] = $package->getSourceType();
$data['source']['url'] = $package->getSourceUrl();
$data['source']['reference'] = $package->getSourceReference();
}
if ($package->getDistType()) {
$data['dist']['type'] = $package->getDistType();
$data['dist']['url'] = $package->getDistUrl();
$data['dist']['reference'] = $package->getDistReference();
$data['dist']['shasum'] = $package->getDistSha1Checksum();
}
if ($package->getArchiveExcludes()) {
$data['archive']['exclude'] = $package->getArchiveExcludes();
}
foreach (BasePackage::$supportedLinkTypes as $type => $opts) {
if ($links = $package->{'get' . ucfirst($opts['method'])}()) {
foreach ($links as $link) {
$data[$type][$link->getTarget()] = $link->getPrettyConstraint();
}
ksort($data[$type]);
}
}
if ($packages = $package->getSuggests()) {
ksort($packages);
$data['suggest'] = $packages;
}
if ($package->getReleaseDate()) {
$data['time'] = $package->getReleaseDate()->format('Y-m-d H:i:s');
}
$data = $this->dumpValues($package, $keys, $data);
if ($package instanceof CompletePackageInterface) {
$keys = array('scripts', 'license', 'authors', 'description', 'homepage', 'keywords', 'repositories', 'support');
$data = $this->dumpValues($package, $keys, $data);
if (isset($data['keywords']) && is_array($data['keywords'])) {
sort($data['keywords']);
}
}
if ($package instanceof RootPackageInterface) {
$minimumStability = $package->getMinimumStability();
if ($minimumStability) {
$data['minimum-stability'] = $minimumStability;
}
}
return $data;
}
示例3: collectLinks
private function collectLinks($noInstallRecommends, $installSuggests)
{
$links = $this->package->getRequires();
if (!$noInstallRecommends) {
$links = array_merge($links, $this->package->getRecommends());
}
if ($installSuggests) {
$links = array_merge($links, $this->package->getSuggests());
}
return $links;
}
示例4: dump
public function dump(PackageInterface $package)
{
$keys = array('binaries' => 'bin', 'scripts', 'type', 'extra', 'installationSource' => 'installation-source', 'license', 'authors', 'description', 'homepage', 'keywords', 'autoload', 'repositories', 'includePaths' => 'include-path', 'support');
$data = array();
$data['name'] = $package->getPrettyName();
$data['version'] = $package->getPrettyVersion();
$data['version_normalized'] = $package->getVersion();
if ($package->getTargetDir()) {
$data['target-dir'] = $package->getTargetDir();
}
if ($package->getReleaseDate()) {
$data['time'] = $package->getReleaseDate()->format('Y-m-d H:i:s');
}
if ($package->getSourceType()) {
$data['source']['type'] = $package->getSourceType();
$data['source']['url'] = $package->getSourceUrl();
$data['source']['reference'] = $package->getSourceReference();
}
if ($package->getDistType()) {
$data['dist']['type'] = $package->getDistType();
$data['dist']['url'] = $package->getDistUrl();
$data['dist']['reference'] = $package->getDistReference();
$data['dist']['shasum'] = $package->getDistSha1Checksum();
}
foreach (BasePackage::$supportedLinkTypes as $type => $opts) {
if ($links = $package->{'get' . ucfirst($opts['method'])}()) {
foreach ($links as $link) {
$data[$type][$link->getTarget()] = $link->getPrettyConstraint();
}
}
}
if ($packages = $package->getSuggests()) {
$data['suggest'] = $packages;
}
foreach ($keys as $method => $key) {
if (is_numeric($method)) {
$method = $key;
}
$getter = 'get' . ucfirst($method);
$value = $package->{$getter}();
if (null !== $value && !(is_array($value) && 0 === count($value))) {
$data[$key] = $value;
}
}
return $data;
}
示例5: updateInformation
//.........这里部分代码省略.........
if ('' === $authorData[$field]) {
$authorData[$field] = null;
}
} else {
$authorData[$field] = null;
}
}
// skip authors with no information
if (!isset($authorData['email']) && !isset($authorData['name'])) {
continue;
}
$author = $authorRepository->findOneBy(array('email' => $authorData['email'], 'name' => $authorData['name'], 'homepage' => $authorData['homepage'], 'role' => $authorData['role']));
if (!$author) {
$author = new Author();
$em->persist($author);
}
foreach (array('email', 'name', 'homepage', 'role') as $field) {
if (isset($authorData[$field])) {
$author->{'set' . $field}($authorData[$field]);
}
}
// only update the author timestamp once a month at most as the value is kinda unused
if ($author->getUpdatedAt() === null || $author->getUpdatedAt()->getTimestamp() < time() - 86400 * 30) {
$author->setUpdatedAt(new \DateTime());
}
if (!$version->getAuthors()->contains($author)) {
$version->addAuthor($author);
}
if (!$author->getVersions()->contains($version)) {
$author->addVersion($version);
}
}
}
// handle links
foreach ($this->supportedLinkTypes as $linkType => $opts) {
$links = array();
foreach ($data->{$opts['method']}() as $link) {
$constraint = $link->getPrettyConstraint();
if (false !== strpos($constraint, ',') && false !== strpos($constraint, '@')) {
$constraint = preg_replace_callback('{([><]=?\\s*[^@]+?)@([a-z]+)}i', function ($matches) {
if ($matches[2] === 'stable') {
return $matches[1];
}
return $matches[1] . '-' . $matches[2];
}, $constraint);
}
$links[$link->getTarget()] = $constraint;
}
foreach ($version->{'get' . $linkType}() as $link) {
// clear links that have changed/disappeared (for updates)
if (!isset($links[$link->getPackageName()]) || $links[$link->getPackageName()] !== $link->getPackageVersion()) {
$version->{'get' . $linkType}()->removeElement($link);
$em->remove($link);
} else {
// clear those that are already set
unset($links[$link->getPackageName()]);
}
}
foreach ($links as $linkPackageName => $linkPackageVersion) {
$class = 'Packagist\\WebBundle\\Entity\\' . $opts['entity'];
$link = new $class();
$link->setPackageName($linkPackageName);
$link->setPackageVersion($linkPackageVersion);
$version->{'add' . $linkType . 'Link'}($link);
$link->setVersion($version);
$em->persist($link);
}
}
// handle suggests
if ($suggests = $data->getSuggests()) {
foreach ($version->getSuggest() as $link) {
// clear links that have changed/disappeared (for updates)
if (!isset($suggests[$link->getPackageName()]) || $suggests[$link->getPackageName()] !== $link->getPackageVersion()) {
$version->getSuggest()->removeElement($link);
$em->remove($link);
} else {
// clear those that are already set
unset($suggests[$link->getPackageName()]);
}
}
foreach ($suggests as $linkPackageName => $linkPackageVersion) {
$link = new SuggestLink();
$link->setPackageName($linkPackageName);
$link->setPackageVersion($linkPackageVersion);
$version->addSuggestLink($link);
$link->setVersion($version);
$em->persist($link);
}
} elseif (count($version->getSuggest())) {
// clear existing suggests if present
foreach ($version->getSuggest() as $link) {
$em->remove($link);
}
$version->getSuggest()->clear();
}
if (!$package->getVersions()->contains($version)) {
$package->addVersions($version);
}
return true;
}
示例6: getSuggests
/**
* {@inheritdoc}
*/
public function getSuggests()
{
return $this->package->getSuggests();
}
示例7: updateInformation
//.........这里部分代码省略.........
if ($data->getAuthors()) {
foreach ($data->getAuthors() as $authorData) {
$author = null;
// skip authors with no information
if (empty($authorData['email']) && empty($authorData['name'])) {
continue;
}
if (!empty($authorData['email'])) {
$author = $authorRepository->findOneByEmail($authorData['email']);
}
if (!$author && !empty($authorData['homepage'])) {
$author = $authorRepository->findOneBy(array('name' => $authorData['name'], 'homepage' => $authorData['homepage']));
}
if (!$author && !empty($authorData['name'])) {
$author = $authorRepository->findOneByNameAndPackage($authorData['name'], $package);
}
if (!$author) {
$author = new Author();
$em->persist($author);
}
foreach (array('email', 'name', 'homepage', 'role') as $field) {
if (isset($authorData[$field])) {
$author->{'set' . $field}($authorData[$field]);
}
}
$author->setUpdatedAt(new \DateTime());
if (!$version->getAuthors()->contains($author)) {
$version->addAuthor($author);
}
if (!$author->getVersions()->contains($version)) {
$author->addVersion($version);
}
}
}
// handle links
foreach ($this->supportedLinkTypes as $linkType => $opts) {
$links = array();
foreach ($data->{$opts['method']}() as $link) {
$constraint = $link->getPrettyConstraint();
if (false !== strpos($constraint, '~')) {
$constraint = str_replace(array('[', ']'), '', $link->getConstraint());
$constraint = preg_replace('{(\\d\\.\\d)(\\.0)+(?=$|,|-)}', '$1', $constraint);
$constraint = preg_replace('{([><=,]) }', '$1', $constraint);
$constraint = preg_replace('{(<[0-9.]+)-dev}', '$1', $constraint);
}
if (false !== strpos($constraint, ',') && false !== strpos($constraint, '@')) {
$constraint = preg_replace_callback('{([><]=?\\s*[^@]+?)@([a-z]+)}i', function ($matches) {
if ($matches[2] === 'stable') {
return $matches[1];
}
return $matches[1] . '-' . $matches[2];
}, $constraint);
}
$links[$link->getTarget()] = $constraint;
}
foreach ($version->{'get' . $linkType}() as $link) {
// clear links that have changed/disappeared (for updates)
if (!isset($links[$link->getPackageName()]) || $links[$link->getPackageName()] !== $link->getPackageVersion()) {
$version->{'get' . $linkType}()->removeElement($link);
$em->remove($link);
} else {
// clear those that are already set
unset($links[$link->getPackageName()]);
}
}
foreach ($links as $linkPackageName => $linkPackageVersion) {
$class = 'Packagist\\WebBundle\\Entity\\' . $opts['entity'];
$link = new $class();
$link->setPackageName($linkPackageName);
$link->setPackageVersion($linkPackageVersion);
$version->{'add' . $linkType . 'Link'}($link);
$link->setVersion($version);
$em->persist($link);
}
}
// handle suggests
if ($suggests = $data->getSuggests()) {
foreach ($version->getSuggest() as $link) {
// clear links that have changed/disappeared (for updates)
if (!isset($suggests[$link->getPackageName()]) || $suggests[$link->getPackageName()] !== $link->getPackageVersion()) {
$version->getSuggest()->removeElement($link);
$em->remove($link);
} else {
// clear those that are already set
unset($suggests[$link->getPackageName()]);
}
}
foreach ($suggests as $linkPackageName => $linkPackageVersion) {
$link = new SuggestLink();
$link->setPackageName($linkPackageName);
$link->setPackageVersion($linkPackageVersion);
$version->addSuggestLink($link);
$link->setVersion($version);
$em->persist($link);
}
}
if (!$package->getVersions()->contains($version)) {
$package->addVersions($version);
}
}
示例8: getSuggests
public function getSuggests()
{
return $this->aliasOf->getSuggests();
}