I want my front controller to serve an xml type and for that reason i need that controller to use a layout that doesn't include any html tags.
On my controller class i have the following code:
<?php
namespace Vendor\Module\Controller\Feed;
use Magento\Framework\View\Result\PageFactory;
use Magento\Framework\App\Action\Context;
class Index extends \Magento\Framework\App\Action\Action
{
protected $pageFactory;
public function __construct(Context $context, PageFactory $pageFactory)
{
$this->pageFactory = $pageFactory;
return parent::__construct($context);
}
public function execute()
{
// $this->getResponse()->setHeader('Content-Type','text/xml');
$page_object = $this->pageFactory->create();
return $page_object;
}
}
The pageFactory object seems to be including the theme's base layout.
Overriding the <container name="root">
node on this controller-action layout, doesn't stop it from rendering head and body tags.
Is there a different object i should be using in the execute() function? What would be the correct way of getting the front controller to use an empty layout?