Magento 2: How get setted URL
-
14-04-2021 - |
Question
I have question, for example, we have some redirect:
class toto extends \Magento\Framework\App\Action\Action
{
protected $_resultPageFactory;
protected $_resulFactory;
public function __construct(
\Magento\Framework\App\Action\Context $context,
\Magento\Framework\View\Result\PageFactory $resultPageFactory,
\Magento\Framework\Controller\ResultFactory $resulFactory,
)
{
parent::__construct($context);
$this->_resultPageFactory = $resultPageFactory;
$this->_resultFactory = $resulFactory;
}
public function execute()
{
$resultRedirect = $this->_resultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT);
$resultRedirect->setPath('homepage.html');
return $resultRedirect;
}
And question is:"how in this controller i can get this redirect url. For example i want add new checking, if redirect url page equal 'homepage':
public function execute()
{
$resultRedirect = $this->_resultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT);
$resultRedirect->setPath('homepage.html');
if('get redirect url' == 'homepage')
{
//some code
$resultRedirect->setPath('bar.html');
}
return $resultRedirect;
}
So how can i get url after setPath method?
No correct solution
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange