Skip to content

Commit

Permalink
Merge pull request #19 from experius/410-response
Browse files Browse the repository at this point in the history
[BUGFIX] Forward to 410 instate of redirecting to the controller to p…
  • Loading branch information
Derrick Heesbeen authored Jan 11, 2018
2 parents 93346ed + 7d230cb commit d5292bb
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Observer/Controller/ActionPredispatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,24 @@ class ActionPredispatch implements \Magento\Framework\Event\ObserverInterface

protected $urlParts = [];

private $resultFactory;

public function __construct(
\Magento\Framework\UrlInterface $url,
\Experius\PageNotFound\Model\PageNotFoundFactory $pageNotFoundFactory,
\Magento\Framework\App\ResponseInterface $response,
\Magento\Framework\App\ActionFactory $actionFactory,
\Magento\Framework\App\Cache\State $cacheState,
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
\Magento\Framework\Controller\ResultFactory $resultFactory
) {
$this->url = $url;
$this->pageNotFoundFactory = $pageNotFoundFactory;
$this->response = $response;
$this->actionFactory = $actionFactory;
$this->cacheState = $cacheState;
$this->scopeConfig = $scopeConfig;
$this->resultFactory = $resultFactory;
}

private function isEnabled(){
Expand Down Expand Up @@ -151,7 +155,8 @@ protected function redirect($url)
{

if($url=='410'){
$url = $this->url->getUrl('experius_pagenotfound/response/gone', ['_secure' => true]);
$result = $this->resultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_FORWARD);
return $result->setModule('experius_pagenotfound')->setController('response')->forward('gone');
} else {
// add all configured params to redirect url. <included_params_redirect>
$queryStart = ($this->urlHasParams($url)) ? '&' : '?';
Expand Down

0 comments on commit d5292bb

Please sign in to comment.