本文整理汇总了PHP中Composer\Package\PackageInterface::getAuthors方法的典型用法代码示例。如果您正苦于以下问题:PHP PackageInterface::getAuthors方法的具体用法?PHP PackageInterface::getAuthors怎么用?PHP PackageInterface::getAuthors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Composer\Package\PackageInterface
的用法示例。
在下文中一共展示了PackageInterface::getAuthors方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateInformation
private function updateInformation(Package $package, PackageInterface $data, $flags)
{
$em = $this->doctrine->getManager();
$version = new Version();
$normVersion = $data->getVersion();
$existingVersion = $package->getVersion($normVersion);
if ($existingVersion) {
$source = $existingVersion->getSource();
// update if the right flag is set, or the source reference has changed (re-tag or new commit on branch)
if ($source['reference'] !== $data->getSourceReference() || $flags & self::UPDATE_EQUAL_REFS) {
$version = $existingVersion;
} else {
// mark it updated to avoid it being pruned
$existingVersion->setUpdatedAt(new \DateTime());
return false;
}
}
$version->setName($package->getName());
$version->setVersion($data->getPrettyVersion());
$version->setNormalizedVersion($normVersion);
$version->setDevelopment($data->isDev());
$em->persist($version);
$descr = $this->sanitize($data->getDescription());
$version->setDescription($descr);
$package->setDescription($descr);
$version->setHomepage($data->getHomepage());
$version->setLicense($data->getLicense() ?: array());
$version->setPackage($package);
$version->setUpdatedAt(new \DateTime());
$version->setReleasedAt($data->getReleaseDate());
if ($data->getSourceType()) {
$source['type'] = $data->getSourceType();
$source['url'] = $data->getSourceUrl();
$source['reference'] = $data->getSourceReference();
$version->setSource($source);
} else {
$version->setSource(null);
}
if ($data->getDistType()) {
$dist['type'] = $data->getDistType();
$dist['url'] = $data->getDistUrl();
$dist['reference'] = $data->getDistReference();
$dist['shasum'] = $data->getDistSha1Checksum();
$version->setDist($dist);
} else {
$version->setDist(null);
}
if ($data->getType()) {
$type = $this->sanitize($data->getType());
$version->setType($type);
if ($type !== $package->getType()) {
$package->setType($type);
}
}
$version->setTargetDir($data->getTargetDir());
$version->setAutoload($data->getAutoload());
$version->setExtra($data->getExtra());
$version->setBinaries($data->getBinaries());
$version->setIncludePaths($data->getIncludePaths());
$version->setSupport($data->getSupport());
if ($data->getKeywords()) {
$keywords = array();
foreach ($data->getKeywords() as $keyword) {
$keywords[mb_strtolower($keyword, 'UTF-8')] = $keyword;
}
$existingTags = [];
foreach ($version->getTags() as $tag) {
$existingTags[mb_strtolower($tag->getName(), 'UTF-8')] = $tag;
}
foreach ($keywords as $tagKey => $keyword) {
if (isset($existingTags[$tagKey])) {
unset($existingTags[$tagKey]);
continue;
}
$tag = Tag::getByName($em, $keyword, true);
if (!$version->getTags()->contains($tag)) {
$version->addTag($tag);
}
}
foreach ($existingTags as $tag) {
$version->getTags()->removeElement($tag);
}
} elseif (count($version->getTags())) {
$version->getTags()->clear();
}
$authorRepository = $this->doctrine->getRepository('PackagistWebBundle:Author');
$version->getAuthors()->clear();
if ($data->getAuthors()) {
foreach ($data->getAuthors() as $authorData) {
$author = null;
foreach (array('email', 'name', 'homepage', 'role') as $field) {
if (isset($authorData[$field])) {
$authorData[$field] = trim($authorData[$field]);
if ('' === $authorData[$field]) {
$authorData[$field] = null;
}
} else {
$authorData[$field] = null;
}
}
//.........这里部分代码省略.........
示例2: updateInformation
private function updateInformation(OutputInterface $output, RegistryInterface $doctrine, $package, PackageInterface $data)
{
$em = $doctrine->getEntityManager();
$version = new Version();
$version->setName($package->getName());
$version->setNormalizedVersion(preg_replace('{-dev$}i', '', $data->getVersion()));
// check if we have that version yet
foreach ($package->getVersions() as $existingVersion) {
if ($existingVersion->equals($version)) {
// avoid updating newer versions, in case two branches have the same version in their composer.json
if ($existingVersion->getReleasedAt() > $data->getReleaseDate()) {
return;
}
if ($existingVersion->getDevelopment()) {
$version = $existingVersion;
break;
}
return;
}
}
$version->setVersion($data->getPrettyVersion());
$version->setDevelopment(substr($data->getVersion(), -4) === '-dev');
$em->persist($version);
$version->setDescription($data->getDescription());
$package->setDescription($data->getDescription());
$version->setHomepage($data->getHomepage());
$version->setLicense($data->getLicense() ?: array());
$version->setPackage($package);
$version->setUpdatedAt(new \DateTime());
$version->setReleasedAt($data->getReleaseDate());
if ($data->getSourceType()) {
$source['type'] = $data->getSourceType();
$source['url'] = $data->getSourceUrl();
$source['reference'] = $data->getSourceReference();
$version->setSource($source);
}
if ($data->getDistType()) {
$dist['type'] = $data->getDistType();
$dist['url'] = $data->getDistUrl();
$dist['reference'] = $data->getDistReference();
$dist['shasum'] = $data->getDistSha1Checksum();
$version->setDist($dist);
}
if ($data->getType()) {
$version->setType($data->getType());
if ($data->getType() && $data->getType() !== $package->getType()) {
$package->setType($data->getType());
}
}
$version->setTargetDir($data->getTargetDir());
$version->setAutoload($data->getAutoload());
$version->setExtra($data->getExtra());
$version->setBinaries($data->getBinaries());
$version->getTags()->clear();
if ($data->getKeywords()) {
foreach ($data->getKeywords() as $keyword) {
$version->addTag(Tag::getByName($em, $keyword, true));
}
}
$version->getAuthors()->clear();
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 = $doctrine->getRepository('PackagistWebBundle:Author')->findOneByEmail($authorData['email']);
}
if (!$author && !empty($authorData['homepage'])) {
$author = $doctrine->getRepository('PackagistWebBundle:Author')->findOneBy(array('name' => $authorData['name'], 'homepage' => $authorData['homepage']));
}
if (!$author && !empty($authorData['name'])) {
$author = $doctrine->getRepository('PackagistWebBundle:Author')->findOneByNameAndPackage($authorData['name'], $package);
}
if (!$author) {
$author = new Author();
$em->persist($author);
}
foreach (array('email', 'name', 'homepage') 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);
}
}
}
foreach ($this->supportedLinkTypes as $linkType => $linkEntity) {
$links = array();
foreach ($data->{'get' . $linkType . 's'}() as $link) {
$links[$link->getTarget()] = $link->getPrettyConstraint();
}
foreach ($version->{'get' . $linkType}() as $link) {
//.........这里部分代码省略.........
示例3: updateInformation
private function updateInformation(Package $package, PackageInterface $data, $flags)
{
$em = $this->doctrine->getEntityManager();
$version = new Version();
$version->setNormalizedVersion($data->getVersion());
// check if we have that version yet
foreach ($package->getVersions() as $existingVersion) {
if ($existingVersion->getNormalizedVersion() === $version->getNormalizedVersion()) {
if ($existingVersion->getDevelopment() || $flags & self::UPDATE_TAGS) {
$version = $existingVersion;
break;
}
// mark it updated to avoid it being pruned
$existingVersion->setUpdatedAt(new \DateTime());
return;
}
}
$version->setName($package->getName());
$version->setVersion($data->getPrettyVersion());
$version->setDevelopment($data->isDev());
$em->persist($version);
$version->setDescription($data->getDescription());
$package->setDescription($data->getDescription());
$version->setHomepage($data->getHomepage());
$version->setLicense($data->getLicense() ?: array());
$version->setPackage($package);
$version->setUpdatedAt(new \DateTime());
$version->setReleasedAt($data->getReleaseDate());
if ($data->getSourceType()) {
$source['type'] = $data->getSourceType();
$source['url'] = $data->getSourceUrl();
$source['reference'] = $data->getSourceReference();
$version->setSource($source);
}
if ($data->getDistType()) {
$dist['type'] = $data->getDistType();
$dist['url'] = $data->getDistUrl();
$dist['reference'] = $data->getDistReference();
$dist['shasum'] = $data->getDistSha1Checksum();
$version->setDist($dist);
}
if ($data->getType()) {
$version->setType($data->getType());
if ($data->getType() && $data->getType() !== $package->getType()) {
$package->setType($data->getType());
}
}
$version->setTargetDir($data->getTargetDir());
$version->setAutoload($data->getAutoload());
$version->setExtra($data->getExtra());
$version->setBinaries($data->getBinaries());
$version->setIncludePaths($data->getIncludePaths());
$version->setSupport($data->getSupport());
$version->getTags()->clear();
if ($data->getKeywords()) {
foreach ($data->getKeywords() as $keyword) {
$tag = Tag::getByName($em, $keyword, true);
if (!$version->getTags()->contains($tag)) {
$version->addTag($tag);
}
}
}
$authorRepository = $this->doctrine->getRepository('PackagistWebBundle:Author');
$version->getAuthors()->clear();
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) {
//.........这里部分代码省略.........
示例4: getAuthors
public function getAuthors()
{
return $this->aliasOf->getAuthors();
}