/** * @param string $operationId * @return string * @throws \Exception */ public function execute($operationId) { $this->newsitem = $this->em->getRepository('CampaignChainOperationLinkedInBundle:NewsItem')->findOneByOperation($operationId); if (!$this->newsitem) { throw new \Exception('No Linkedin news item found for an operation with ID: ' . $operationId); } $activity = $this->newsitem->getOperation()->getActivity(); $connection = $this->client->getConnectionByActivity($activity); $this->message = $connection->getCompanyUpdate($activity, $this->newsitem); $likes = 0; if (isset($response['numLikes'])) { $likes = $response['numLikes']; } $comments = 0; if (isset($response['updateComments']) && isset($response['updateComments']['_total'])) { $comments = $response['updateComments']['_total']; } // Add report data. $facts[self::METRIC_LIKES] = $likes; $facts[self::METRIC_COMMENTS] = $comments; $this->factService->addFacts('activity', self::BUNDLE_NAME, $this->newsitem->getOperation(), $facts); return self::STATUS_OK; }