It would help if someone could indicate what resultFactory is set to?
i.e. I see a lot of $this->resultfactory->.... but there isn't any code about what class this is set to, it would help to place the content of it's __construct function to help others.
After some research, I found the class, here is an example of what it should be:
\Magento\Framework\Controller\ResultFactory
The __constructor code therefore would be:
public function __construct
(
\Magento\Framework\App\Action\Context $context
.
.
.
, \Magento\Framework\Controller\ResultFactory $ResultFactory
)
{
$this->ResultFactory = $ResultFactory;
parent::__construct ( ... );
}
Calling it will be by using:
$Response = $this->ResultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_PAGE);
Finally, to get the page/block out, we do:
$Response = $this->ResultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_PAGE);
$layout = $Response->addHandle('my_layout_xml_file_whatever_it_is')->getLayout();
$Response = $layout->getBlock('my_block_name_goes_here_from_the_xml')->toHtml();
$this->getResponse()->setBody($Response);
return;
I hope this helps with the answer.