Suin\RSSWriter\Item::appendTo PHP 메소드

appendTo() 공개 메소드

public appendTo ( Suin\RSSWriter\ChannelInterface $channel )
$channel Suin\RSSWriter\ChannelInterface
    public function appendTo(ChannelInterface $channel)
    {
        $channel->addItem($this);
        return $this;
    }

Usage Example

예제 #1
0
파일: Content.php 프로젝트: phpffcms/ffcms
 /**
  * Display rss feeds from content category
  * @return string
  * @throws ForbiddenException
  */
 public function actionRss()
 {
     $path = $this->request->getPathWithoutControllerAction();
     $configs = $this->getConfigs();
     // build model data
     $model = new EntityCategoryList($path, $configs, 0);
     // remove global layout
     $this->layout = null;
     // check if rss display allowed for this category
     if ((int) $model->category['configs']['showRss'] !== 1) {
         throw new ForbiddenException(__('Rss feed is disabled for this category'));
     }
     // initialize rss feed objects
     $feed = new Feed();
     $channel = new Channel();
     // set channel data
     $channel->title($model->category['title'])->description($model->category['description'])->url(App::$Alias->baseUrl . '/content/list/' . $model->category['path'])->appendTo($feed);
     // add content data
     if ($model->getContentCount() > 0) {
         foreach ($model->items as $row) {
             $item = new Item();
             // add title, short text, url
             $item->title($row['title'])->description($row['text'])->url(App::$Alias->baseUrl . $row['uri']);
             // add poster
             if ($row['thumb'] !== null) {
                 $item->enclosure(App::$Alias->scriptUrl . $row['thumb'], $row['thumbSize'], 'image/jpeg');
             }
             // append response to channel
             $item->appendTo($channel);
         }
     }
     // define rss read event
     App::$Event->run(static::EVENT_RSS_READ, ['model' => $model, 'feed' => $feed, 'channel' => $channel]);
     // render response from feed object
     return $feed->render();
 }
All Usage Examples Of Suin\RSSWriter\Item::appendTo