![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/magento/framework/Controller/Result/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ namespace Magento\Framework\Controller\Result; use Magento\Framework\App; use Magento\Framework\App\Response\HttpInterface as HttpResponseInterface; use Magento\Framework\Controller\AbstractResult; use Magento\Framework\App\Response\RedirectInterface; use Magento\Framework\UrlInterface; /** * In many cases controller actions may result in a redirect * so this is a result object that implements all necessary properties of a HTTP redirect * * @api * @since 100.0.2 */ class Redirect extends AbstractResult { /** * @var RedirectInterface */ protected $redirect; /** * @var UrlInterface */ protected $urlBuilder; /** * @var string */ protected $url; /** * Constructor * * @param App\Response\RedirectInterface $redirect * @param UrlInterface $urlBuilder */ public function __construct( App\Response\RedirectInterface $redirect, UrlInterface $urlBuilder ) { $this->redirect = $redirect; $this->urlBuilder = $urlBuilder; } /** * Set url from referer * * @return $this */ public function setRefererUrl() { $this->url = $this->redirect->getRefererUrl(); return $this; } /** * Set referer url or base if referer is not exist * * @return $this */ public function setRefererOrBaseUrl() { $this->url = $this->redirect->getRedirectUrl(); return $this; } /** * URL Setter * @param string $url * @return $this */ public function setUrl($url) { $this->url = $url; return $this; } /** * Set url by path * * @param string $path * @param array $params * @return $this */ public function setPath($path, array $params = []) { $this->url = $this->urlBuilder->getUrl($path, $this->redirect->updatePathParams($params)); return $this; } /** * {@inheritdoc} */ protected function render(HttpResponseInterface $response) { if (empty($this->httpResponseCode)) { $response->setRedirect($this->url); } else { $response->setRedirect($this->url, $this->httpResponseCode); } return $this; } }