Example #1
0
 /**
  * Render link to news item or internal/external pages
  *
  * @param \GeorgRinger\News\Domain\Model\News $newsItem current news object
  * @param array $settings
  * @param boolean $uriOnly return only the url without the a-tag
  * @param array $configuration optional typolink configuration
  * @param string $content optional content which is linked
  * @return string link
  */
 public function render(\GeorgRinger\News\Domain\Model\News $newsItem, array $settings = array(), $uriOnly = FALSE, $configuration = array(), $content = '')
 {
     $tsSettings = $this->pluginSettingsService->getSettings();
     $this->init();
     $newsType = (int) $newsItem->getType();
     switch ($newsType) {
         // internal news
         case 1:
             $configuration['parameter'] = $newsItem->getInternalurl();
             break;
             // external news
         // external news
         case 2:
             $configuration['parameter'] = $newsItem->getExternalurl();
             break;
             // normal news record
         // normal news record
         default:
             $configuration = $this->getLinkToNewsItem($newsItem, $tsSettings, $configuration);
     }
     if (isset($tsSettings['link']['typesOpeningInNewWindow'])) {
         if (GeneralUtility::inList($tsSettings['link']['typesOpeningInNewWindow'], $newsType)) {
             $this->tag->addAttribute('target', '_blank');
         }
     }
     $url = $this->cObj->typoLink_URL($configuration);
     if ($uriOnly) {
         return $url;
     }
     $this->tag->addAttribute('href', $url);
     if (empty($content)) {
         $content = $this->renderChildren();
     }
     $this->tag->setContent($content);
     return $this->tag->render();
 }
Example #2
0
 /**
  * Test if type can be set
  *
  * @test
  * @return void
  */
 public function typeCanBeSet()
 {
     $type = 123;
     $this->newsDomainModelInstance->setType($type);
     $this->assertEquals($type, $this->newsDomainModelInstance->getType());
 }