Beispiel #1
0
 /**
  * @param News $message
  *
  * @return array
  */
 private function formatNewsForPush(News $message)
 {
     $articles = [];
     foreach ($message->getItems() as $item) {
         $article = ['title' => $item->getTitle(), 'description' => $item->getDescription()];
         if ($item->getURL() !== null) {
             $article['url'] = $item->getURL();
         }
         if ($item->getImageURL() !== null) {
             $article['picurl'] = $item->getImageURL();
         }
         $articles[] = $article;
     }
     return ['articles' => $articles];
 }
Beispiel #2
0
 /**
  * Sends a new message reply.
  * 
  * @param Type\News $newsMessage
  *
  * @throws Exception\AlreadySentException
  */
 public function sendNews(Type\News $newsMessage)
 {
     // Build up items.
     $items = [];
     foreach ($newsMessage->getItems() as $newsItem) {
         $items[] = ['Title' => $newsItem->getTitle(), 'Description' => $newsItem->getDescription(), 'PicUrl' => $newsItem->getImageURL(), 'Url' => $newsItem->getURL()];
     }
     $this->sendReply($this->buildMessage(['MsgType' => $newsMessage->getType(), 'ArticleCount' => count($items), 'Articles' => ['item' => $items]]));
 }