<?php

namespace j0k3r\FeedBundle\Parser;

/**
 * HackernewsParser
 *
 * This class provides a custom parser for news.ycombinator.com feed
 */
class HackernewsParser extends DefaultParser
{
    /**
     * We just append the readable content to the default content.
     * In fact, we transform the "Comments" link, to something a bit more friendly
     */
    public function updateContent($content)
    {
        $url_parts = parse_url($this->url);

        return '<p><em>Original article on <a href="'.$this->url.'">'.$url_parts['host'].'</a></em></p> '.$content;
    }
}

<?php

namespace j0k3r\FeedBundle\Parser;

/**
 * HackernewsParser
 *
 * This class provides a custom parser for news.ycombinator.com feed
 */
class HackernewsParser extends DefaultParser
{
    /**
     * We append the readable content to something a bit more friendly:
     * - a link to the original article with the host as value
     * - a link to comments on Hacker News
     */
    public function updateContent($content)
    {
        $url_parts = parse_url($this->url);

        // $itemContent for HackerNews feed contains only a link to the HN page with "Comments" as name
        return '<p><em>Original article on <a href="'.$this->url.'">'.$url_parts['host'].'</a> - '.$this->itemContent.' on Hacker News</em></p> '.$content;
    }
}

Add comments link to the HN thread
Add comments link to the HN thread