getId() public method

Get id
public getId ( ) : string
return string
Exemplo n.º 1
0
 /**
  * Finds the Score object for a given date and bundle
  *
  * @param DateTime $date
  * @param Bundle $bundle
  * @return Score or null
  */
 public function findOneByDateAndBundle(\DateTime $date, Bundle $bundle)
 {
     try {
         return $this->createQueryBuilder('s')->where('s.bundle = :bundle_id')->andWhere('s.date = :date')->setParameter('bundle_id', $bundle->getId())->setParameter('date', $date->format('Y-m-d'))->getQuery()->getSingleResult();
     } catch (NoResultException $e) {
         return null;
     }
 }
Exemplo n.º 2
0
 /**
  * @param Bundle  $bundle
  * @param integer $limit
  *
  * @return array
  */
 public function findLastActivitiesForBundle(Bundle $bundle, $limit = 10)
 {
     $query = $this->queryLastActivities(null, $bundle->getId(), null);
     if (null !== $limit) {
         $query->setMaxResults($limit);
     }
     return $query->execute();
 }
Exemplo n.º 3
0
 /**
  * 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));
 }
Exemplo n.º 4
0
 /**
  * Updates bundle score
  *
  * @param Bundle $bundle
  * @param object $repository
  */
 private function updateScore(Bundle $bundle, $repository)
 {
     if (!$bundle->hasChanges()) {
         return;
     }
     $score = $repository->findOneBy(array('date' => new \DateTime(), 'bundle' => $bundle->getId()));
     if (!$score) {
         $score = new Score();
         $score->setBundle($bundle);
     }
     $score->setValue($bundle->getScore());
     $this->em->persist($score);
     $this->em->flush();
 }
Exemplo n.º 5
0
 /**
  * @param Bundle $bundle
  *
  * @return boolean
  */
 public function removeRepo(Bundle $bundle)
 {
     if ($this->bundleUpdateProducer) {
         // Create a Message object
         $message = array('bundle_id' => $bundle->getId(), 'action' => 'remove');
         // RabbitMQ, publish my message!
         $this->bundleUpdateProducer->publish(json_encode($message));
         return true;
     }
     return false;
 }
Exemplo n.º 6
0
 /**
  * @param Activity $activity
  *
  * @return boolean
  */
 public function isEqualTo(Activity $activity)
 {
     if ($activity->getBundle()->getId() !== $this->bundle->getId()) {
         return false;
     }
     // Compare developers only if actual activity has one
     if (null !== $this->developer && $activity->getDeveloper()->getId() !== $this->developer->getId()) {
         return false;
     }
     if ($activity->getType() !== $this->type) {
         return false;
     }
     if ($activity->getState() !== $this->state) {
         return false;
     }
     // Compare dates only when state of activity allows it
     if (self::STATE_FIXED !== $this->state && $activity->getCreatedAt()->getTimestamp() !== $this->createdAt->getTimestamp()) {
         return false;
     }
     return true;
 }