FeedWriter\Feed::printFeed PHP Method

printFeed() public method

Sets a Content-Type header and echoes the contents of the feed. Should only be used in situations where direct output is desired; if you need to pass a string around, use generateFeed() instead.
public printFeed ( $useGenericContentType = false ) : void
return void
    public function printFeed($useGenericContentType = false)
    {
        if (!is_bool($useGenericContentType)) {
            throw new \InvalidArgumentException('The useGenericContentType parameter must be boolean.');
        }
        $contentType = "text/xml";
        if (!$useGenericContentType) {
            $contentType = $this->getMIMEType();
        }
        // Generate the feed before setting the header, so Exceptions will be nicely visible.
        $feed = $this->generateFeed();
        header("Content-Type: " . $contentType . "; charset=" . $this->encoding);
        echo $feed;
    }