Knp\Bundle\KnpBundlesBundle\Github\Repo::getContributorNames PHP Method

getContributorNames() public method

public getContributorNames ( Bundle $bundle )
$bundle Knp\Bundle\KnpBundlesBundle\Entity\Bundle
    public function getContributorNames(Bundle $bundle)
    {
        try {
            $contributors = $this->github->api('repo')->contributors($bundle->getOwnerName(), $bundle->getName());
        } catch (RuntimeException $e) {
            return array();
        }
        $names = array();
        foreach ($contributors as $contributor) {
            if ($bundle->getOwnerName() != $contributor['login']) {
                $names[] = $contributor['login'];
            }
        }
        return $names;
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * Takes a bundle and update its contributors
  *
  * @param Bundle $bundle
  */
 private function updateContributors(Bundle $bundle)
 {
     $contributorNames = $this->githubRepoApi->getContributorNames($bundle);
     $contributors = array();
     foreach ($contributorNames as $contributorName) {
         $contributors[] = $this->ownerManager->createOwner($contributorName, 'unknown');
     }
     $bundle->setContributors($contributors);
     if ($this->logger) {
         $this->logger->info(sprintf('%d contributor(s) have been retrieved for bundle %s', count($contributors), $bundle->getName()));
     }
 }