/** * Fetch upstream notifications via RSS. */ public function updateUpstreamNotifications() { $url = $this->coreParametersHelper->getParameter('rss_notification_url'); if (empty($url)) { return; } //check to see when we last checked for an update $lastChecked = $this->session->get('mautic.upstream.checked', 0); if (time() - $lastChecked > 3600) { $this->session->set('mautic.upstream.checked', time()); $lastDate = $this->getRepository()->getUpstreamLastDate(); try { /** @var FeedContent $feed */ $feed = $this->rssReader->getFeedContent($url, $lastDate); /** @var Item $item */ foreach ($feed->getItems() as $item) { $description = $item->getDescription(); if (mb_strlen(strip_tags($description)) > 300) { $description = mb_substr(strip_tags($description), 0, 300); $description .= '... <a href="' . $item->getLink() . '" target="_blank">' . $this->translator->trans('mautic.core.notification.read_more') . '</a>'; } $header = $item->getTitle(); $this->addNotification($description, 'upstream', false, $header ? $header : null, 'fa-bullhorn'); } } catch (\Exception $exception) { $this->logger->addWarning($exception->getMessage()); } } }
/** * @covers Debril\RssAtomBundle\Protocol\FeedReader::parseBody * @expectedException \Debril\RssAtomBundle\Exception\FeedException\FeedCannotBeReadException */ public function testParseBodyUnknownError() { $reader = new FeedReader($this->getMockDriver(666), new Factory()); $reader->getFeedContent('http://afakeurl', new \DateTime()); }