Skip to content

Commit

Permalink
Redirect to the correct URL.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sophie Shanahan-Kluth committed Jun 18, 2020
1 parent d6ebe2e commit e100972
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
9 changes: 7 additions & 2 deletions Observer/DisableFrontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,13 @@ public function execute(ObserverInterface $observer)
$this->redirect->redirect($controller->getResponse(), $this->helperBackend->getHomePageUrl());
}
elseif ($configValue['show_frontend_as'] === 'redirect_to') {
// Check that the URL is valid.
// Redirect to that URL.
if (empty($configValue['redirect_to'])) {
// If there is no redirect destination, then throw an exception.
throw new \LogicException('No redirect destination was found.');
}

// The URL is valid. If it isn't, then the config form can't save.
$this->redirect->redirect($controller->getResponse(), $configValue['redirect_to']);
}
}
}
3 changes: 2 additions & 1 deletion etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
</field>
<field id="redirect_to" translate="label" type="text" sortOrder="2" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Redirect to</label>
<validate>validate-url</validate>
</field>
</group>
</section>
</system>
</config>
</config>
4 changes: 2 additions & 2 deletions etc/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="FocusriteNovation_DisableFrontend" setup_version="1.2.0">
<sequence>
<module name="Magento_Store"/>
<module name="Magento_Store" />
</sequence>
</module>
</config>
</config>

0 comments on commit e100972

Please sign in to comment.