public function validate(Bundle $bundle)
{
$valid = false;
try {
$contentApi = $this->github->api('repo')->contents();
$valid = $this->tryToValidateWithComposerFile($bundle, $contentApi);
if (!$valid) {
$treeApi = $this->github->api('git')->trees();
$valid = $this->tryToValidateWithFiles($bundle, $treeApi, $contentApi);
}
} catch (RuntimeException $e) {
$valid = false;
}
return $valid;
}
/** * @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; }