/**
  * Formats the specified response.
  * @param Response $response the response to be formatted.
  */
 public function format(Response $response)
 {
     $charset = $this->encoding === null ? $response->charset : $this->encoding;
     if (stripos($this->contentType, 'charset') === false) {
         $this->contentType .= '; charset=' . $charset;
     }
     $response->getHeaders()->set('Content-Type', $this->contentType);
     $data = $response->data;
     if (isset($data['language'])) {
         $this->_feedWriter->setChannelElement('language', $data['language']);
     }
     if (!isset($data['pubDate'])) {
         $this->_feedWriter->setChannelElement('pubDate', date(DATE_RSS, time()));
     }
     if (isset($data['title'])) {
         $this->_feedWriter->setTitle($data['title']);
     }
     if (isset($data['link'])) {
         $this->_feedWriter->setLink($data['link']);
     }
     if (isset($data['description'])) {
         $this->_feedWriter->setDescription($data['description']);
     }
     if (isset($data['items']) && is_array($data['items'])) {
         if ($data['items']) {
             foreach ($data['items'] as $item) {
                 $newItem = $this->_feedWriter->createNewItem();
                 $newItem->addElementArray($item);
                 $this->_feedWriter->addItem($newItem);
             }
         }
     }
     $response->content = $this->_feedWriter->generateFeed();
 }