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

updateInfos() public method

Return true if the Repo exists on GitHub, false otherwise
public updateInfos ( Bundle $bundle ) : boolean
$bundle Knp\Bundle\KnpBundlesBundle\Entity\Bundle
return boolean whether the Repo exists on GitHub
    public function updateInfos(Bundle $bundle)
    {
        $this->output->write(' infos');
        try {
            $data = $this->github->api('repo')->show($bundle->getOwnerName(), $bundle->getName());
        } catch (RuntimeException $e) {
            return false;
        }
        // Let's try to only keep a forked repo with lots of watchers
        if ($data['fork'] && $data['watchers'] < 10) {
            return false;
        }
        $bundle->setDescription(empty($data['description']) ? null : $data['description']);
        $bundle->setNbFollowers($data['watchers']);
        $bundle->setNbForks($data['forks']);
        $bundle->setIsFork($data['fork']);
        $bundle->setCreatedAt(new \DateTime($data['created_at']));
        $bundle->setHomepage(empty($data['homepage']) ? null : $data['homepage']);
        return true;
    }

Usage Example

Exemplo n.º 1
0
 /**
  * @param string $name
  * @param string $ownerName
  *
  * @return boolean|Bundle return false if the bundle is not valid
  */
 private function createFullBundle($name, $ownerName)
 {
     $bundle = $this->createEmptyBundle($name);
     $bundle->setOwnerName($ownerName);
     if (!$this->repoApi->validate($bundle)) {
         return false;
     }
     if (!$this->repoApi->updateInfos($bundle)) {
         return false;
     }
     $owner = $this->ownerManager->createOwner($ownerName, 'unknown', false);
     if (!$owner) {
         return false;
     }
     $owner->addBundle($bundle);
     return $bundle;
 }