<?php


namespace Magetop\Advancepreview\Controller\Index;

use Magento\Framework\App\Action\Context;
use Magento\Checkout\Model\Cart as CustomerCart;
class Invoice extends  \Magento\Framework\App\Action\Action
{
    protected $pageFactory;
    public function __construct(
        Context $context,
        \Magento\Framework\View\Result\PageFactory $pageFactory
    )
    {
        parent::__construct($context);
        $this->pageFactory = $pageFactory;
    }

    public function execute()
    {
        $resultPageFactory = $this->pageFactory->create();
        // Add page title
        $resultPageFactory->getConfig()->getTitle()->set(__('View Invoice'));
        // Add breadcrumb
        /** @var \Magento\Theme\Block\Html\Breadcrumbs */
        if($resultPageFactory->getLayout()->getBlock('breadcrumbs'))
        {
            $breadcrumbs = $resultPageFactory->getLayout()->getBlock('breadcrumbs');
            $breadcrumbs->addCrumb('home',
                [
                    'label' => __('Home'),
                    'title' => __('Home'),
                    'link' => $this->_url->getUrl('')
                ]
            );
            $breadcrumbs->addCrumb('preview_custom_view_invoice',
                [
                    'label' => __('View Invoice'),
                    'title' => __('View Invoice')
                ]
            );
        }
        return $resultPageFactory;
    }
}
