/** * @param Activity $activity * @param string $type * * @return string */ public function bundleActivityMessage(Activity $activity, $type = 'long') { switch ($activity->getType()) { case Activity::ACTIVITY_TYPE_COMMIT: return 'long' == $type ? $activity->getMessage() : 'commited into'; break; case Activity::ACTIVITY_TYPE_RECOMMEND: return 'long' == $type ? 'Bundle was recommended' : 'recommended'; break; case Activity::ACTIVITY_TYPE_TRAVIS_BUILD: return ('long' == $type ? 'Travis-CI build of the bundle' : 'CI build') . (Activity::STATE_OPEN == $activity->getState() ? ' passed' : ' failed'); break; case Activity::ACTIVITY_TYPE_TWEETED: return 'long' == $type ? 'Bundle archived top trending badge' : 'archived'; break; default: return $activity->getMessage() ?: 'Various info'; } }
/** * @param Activity $activity * @return array */ public function findAllSimilar(Activity $activity) { return $this->createQueryBuilder('a')->where('a.id != ?1')->andWhere('a.author = ?2')->andWhere('a.bundleName = ?3')->andWhere('a.bundleOwnerName = ?4')->andWhere('a.message = ?5')->andWhere('a.createdAt = ?6')->setParameter(1, $activity->getId())->setParameter(2, $activity->getAuthor())->setParameter(3, $activity->getBundleName())->setParameter(4, $activity->getBundleOwnerName())->setParameter(5, $activity->getMessage())->setParameter(6, $activity->getCreatedAt())->getQuery()->getResult(); }