scopeConfig = $scopeConfig; $this->url = $url; } /** * Redirect review routes to 404 when review module is disabled. * * @param Observer $observer */ public function execute(Observer $observer) { if (!$this->scopeConfig->getValue( self::XML_PATH_REVIEW_ACTIVE, ScopeInterface::SCOPE_STORE ) ) { $defaultNoRouteUrl = $this->scopeConfig->getValue( 'web/default/no_route', ScopeInterface::SCOPE_STORE ); $redirectUrl = $this->url->getUrl($defaultNoRouteUrl); $observer->getControllerAction() ->getResponse() ->setRedirect($redirectUrl); } } }