update() public method

public update ( Bundle $bundle ) : boolean | Bundle
$bundle Knp\Bundle\KnpBundlesBundle\Entity\Bundle
return boolean | Knp\Bundle\KnpBundlesBundle\Entity\Bundle
 /**
  * Callback called from RabbitMQ to update a bundle
  *
  * @param AMQPMessage $msg serialized Message
  */
 public function execute(AMQPMessage $msg)
 {
     // Retrieve informations from the message
     $message = json_decode($msg->body, true);
     if (!isset($message['bundle_id'])) {
         if ($this->logger) {
             $this->logger->err('Bundle id is missing : skip message');
         }
         return;
     }
     $bundles = $this->em->getRepository('Knp\\Bundle\\KnpBundlesBundle\\Entity\\Bundle');
     // Retrieve Bundle from database
     /* @var $bundle Bundle */
     if (!($bundle = $bundles->find($message['bundle_id']))) {
         if ($this->logger) {
             $this->logger->warn(sprintf('Unable to retrieve bundle #%d', $message['bundle_id']));
         }
         return;
     }
     if (isset($message['action']) && 'remove' == $message['action']) {
         if ($this->logger) {
             $this->logger->warn(sprintf('Bundle "%s" will be removed', $bundle->getName()));
         }
         $this->removeBundle($bundle);
         return;
     }
     if ($this->logger) {
         $this->logger->info(sprintf('Retrieved bundle %s', $bundle->getName()));
     }
     $keywordRepo = $this->em->getRepository('Knp\\Bundle\\KnpBundlesBundle\\Entity\\Keyword');
     $scoreRepo = $this->em->getRepository('Knp\\Bundle\\KnpBundlesBundle\\Entity\\Score');
     for ($i = 0; $i < self::MAX_GITHUB_TRIALS; $i++) {
         try {
             if (!$this->githubRepoApi->update($bundle)) {
                 if ($this->logger) {
                     $this->logger->warn(sprintf('Update of "%s" failed', $bundle->getName()));
                 }
                 return;
             }
             $this->indexer->indexBundle($bundle);
             $this->updateContributors($bundle);
             $this->updateKeywords($bundle, $keywordRepo);
             $this->updateScore($bundle, $scoreRepo);
             if ($bundle->getUsesTravisCi()) {
                 $this->travis->update($bundle);
             }
         } catch (ApiLimitExceedException $e) {
             if ($this->logger) {
                 $this->logger->err(sprintf('Bundle %s got a %s for trial %s', $bundle->getName(), $e->getMessage(), $i + 1));
             }
             sleep(60 * ($i + 1));
             continue;
         } catch (\Exception $e) {
             if ($this->logger) {
                 $this->logger->err('[' . get_class($e) . ' / ' . $e->getFile() . ':' . $e->getLine() . '] ' . $e->getMessage());
             }
         }
         break;
     }
 }