/** * Populates document with bundle data. * * @param \Solarium_Document_ReadWrite $document * @param Bundle $bundle * @param \Solarium_Query_Helper $helper */ private function updateDocumentFromBundle(\Solarium_Document_ReadWrite $document, Bundle $bundle, \Solarium_Query_Helper $helper) { $document->setField('id', $bundle->getId()); $document->setField('name', $bundle->getName()); $document->setField('ownerName', $bundle->getOwnerName()); $document->setField('ownerType', $bundle->getOwnerType()); $document->setField('fullName', $bundle->getFullName()); $document->setField('description', $bundle->getDescription()); $document->setField('readme', $bundle->getReadme()); $document->setField('totalScore', $bundle->getScore()); $document->setField('state', $bundle->getState()); $document->setField('avatarUrl', $bundle->getOwner()->getAvatarUrl()); $document->setField('lastCommitAt', $helper->formatDate(clone $bundle->getLastCommitAt())); $document->setField('lastTweetedAt', null !== $bundle->getLastTweetedAt() ? $helper->formatDate($bundle->getLastTweetedAt()) : null); $keywords = array(); foreach ($bundle->getKeywords() as $keyword) { $keywords[mb_strtolower($keyword->getValue(), 'UTF-8')] = true; } $document->setField('keywords', array_keys($keywords)); }
/** * Updates repo based on status from travis. * * @param Bundle $bundle * * @return boolean */ public function update(Bundle $bundle) { $this->output->write(' Travis status:'); $response = $this->browser->get('http://travis-ci.org/' . $bundle->getOwnerName() . '/' . $bundle->getName() . '.json'); $status = json_decode($response->getContent(), true); if (JSON_ERROR_NONE === json_last_error()) { $lastBuildAt = new \DateTime(); $lastBuildAt->setTimestamp(strtotime($status['last_build_finished_at'])); // Only execute if date of last build is older than last update of bundle if ($lastBuildAt < $bundle->getUpdatedAt()) { $state = Activity::STATE_UNKNOWN; if (0 === $status['last_build_status']) { $bundle->setTravisCiBuildStatus(true); $state = Activity::STATE_OPEN; $this->output->write(' success'); } elseif (1 === $status['last_build_status']) { $bundle->setTravisCiBuildStatus(false); $state = Activity::STATE_CLOSED; $this->output->write(' failed'); } if (Activity::STATE_UNKNOWN !== $state) { $activity = new Activity(); $activity->setType(Activity::ACTIVITY_TYPE_TRAVIS_BUILD); $activity->setState($state); $activity->setBundle($bundle); return true; } } else { $this->output->write(' skipped'); return true; } } $bundle->setTravisCiBuildStatus(null); $this->output->write(' error'); return false; }
private function tryToValidateWithComposerFile(Bundle $bundle, Contents $contentApi) { $validComposer = false; try { $file = $contentApi->show($bundle->getOwnerName(), $bundle->getName(), 'composer.json'); $composer = $this->decodeFileContent($file, true); if (JSON_ERROR_NONE === json_last_error()) { if (isset($composer['type']) && false !== strpos(strtolower($composer['type']), 'symfony')) { $validComposer = true; } if (isset($composer['autoload']['psr-0'])) { foreach ($composer['autoload']['psr-0'] as $key => $value) { if (preg_match('/\\\\(.*)(\\w*)Bundle$/', $key) > 0) { $validComposer = true; } } } if (isset($composer['autoload']['psr-4'])) { foreach ($composer['autoload']['psr-4'] as $key => $value) { if (preg_match('/\\\\(.*)(\\w*)Bundle$/', $key) > 0) { $validComposer = true; } } } } } catch (RuntimeException $e) { $validComposer = false; } return $validComposer; }
public function bundleTravisUrl(Bundle $bundle) { return $bundle->getUsesTravisCi() ? sprintf('http://travis-ci.org/%s/%s', $bundle->getOwnerName(), $this->getName()) : null; }
/** * @param Bundle $bundle */ public function setBundle(Bundle $bundle) { $this->bundle = $bundle; $this->bundleName = $bundle->getName(); $this->bundleOwnerName = $bundle->getOwnerName(); $bundle->addActivity($this); }
/** * @param \Knp\Bundle\KnpBundlesBundle\Entity\Bundle $bundle * @return string */ protected function getRepoDir(BundleEntity $repo) { return $this->dir . DIRECTORY_SEPARATOR . $repo->getOwnerName() . DIRECTORY_SEPARATOR . $repo->getName(); }
/** * @param Bundle $trendingBundle * * @return string */ private function prepareMessage(Bundle $trendingBundle) { $bundleName = $trendingBundle->getName(); $url = 'knpbundles.com/' . $trendingBundle->getOwnerName() . '/' . $bundleName; return str_replace(array('{name}', '{url}'), array($bundleName, $url), $this->twitterParams['tweet_template']); }
/** * Get badge image full path * * @param Bundle $bundle * @param string $type * * @return string */ protected function getBadgeFile(Bundle $bundle, $type = self::LONG) { return $this->cacheDir . '/badges/' . $type . '/' . $bundle->getOwnerName() . '-' . $bundle->getName() . '.png'; }