forked from abelbm/magento2-disable-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename to FocusriteNovation and some tidy ups.
- Loading branch information
Sophie Shanahan-Kluth
committed
Jun 18, 2020
1 parent
7f90d46
commit b5c254d
Showing
10 changed files
with
74 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
/nbproject/* | ||
/nbproject/* | ||
/vendor/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,35 @@ | ||
<?php | ||
namespace Abelbm\DisableFrontend\Observer; | ||
|
||
namespace FocusriteNovation\DisableFrontend\Observer; | ||
|
||
use FocusriteNovation\DisableFrontend\Helper\Data as DisableFrontendHelper; | ||
use Magento\Framework\Event\ObserverInterface; | ||
use Magento\Framework\App\ActionFlag; | ||
use Magento\Framework\App\Action\Action; | ||
use Magento\Framework\App\Response\RedirectInterface; | ||
use Magento\Backend\Helper\Data; | ||
use Abelbm\DisableFrontend\Helper\Data as DisableFrontendHelper; | ||
|
||
class DisableFrontend implements ObserverInterface{ | ||
class DisableFrontend implements ObserverInterface { | ||
|
||
protected $_actionFlag; | ||
protected $redirect; | ||
private $helperBackend; | ||
private $logger; | ||
private $disableFrontendHelper; | ||
/** | ||
* @var Magento\Framework\App\ActionFlag; | ||
*/ | ||
protected $_actionFlag; | ||
|
||
/** | ||
* @var Magento\Framework\App\Response\RedirectInterface | ||
*/ | ||
protected $redirect; | ||
|
||
/** | ||
* @var Magento\Backend\Helper\Data | ||
*/ | ||
private $helperBackend; | ||
|
||
/** | ||
* @var FocusriteNovation\DisableFrontend\Helper\Data | ||
*/ | ||
private $disableFrontendHelper; | ||
|
||
/** | ||
* DisableFrontend constructor. | ||
|
@@ -22,19 +39,16 @@ class DisableFrontend implements ObserverInterface{ | |
* @param RedirectInterface $redirect | ||
* @param Data $helperBackend | ||
* @param DisableFrontendHelper $disableFrontendHelper | ||
* @param \Psr\Log\LoggerInterface $logger | ||
*/ | ||
public function __construct( | ||
ActionFlag $actionFlag, | ||
RedirectInterface $redirect, | ||
Data $helperBackend, | ||
DisableFrontendHelper $disableFrontendHelper, | ||
\Psr\Log\LoggerInterface $logger | ||
) { | ||
$this->_actionFlag = $actionFlag; | ||
$this->redirect = $redirect; | ||
$this->helperBackend = $helperBackend; | ||
$this->logger = $logger; | ||
$this->disableFrontendHelper = $disableFrontendHelper; | ||
} | ||
|
||
|
@@ -44,16 +58,15 @@ public function __construct( | |
* Stores > Configuration > Advanced > Admin > Disable Frontend | ||
* | ||
* @author Abel Bolanos Martinez <[email protected]> | ||
* @param \Magento\Framework\Event\Observer $observer | ||
* @param \Magento\Framework\Event\ObserverInterface $observer | ||
* @return void | ||
*/ | ||
public function execute(\Magento\Framework\Event\Observer $observer){ | ||
|
||
//$this->logger->info('TEST'); | ||
|
||
$this->_actionFlag->set('', \Magento\Framework\App\Action\Action::FLAG_NO_DISPATCH, true); | ||
public function execute(ObserverInterface $observer) | ||
{ | ||
$this->_actionFlag->set('', Action::FLAG_NO_DISPATCH, true); | ||
|
||
if($this->disableFrontendHelper->getConfigValue()){//redirect to Admin | ||
if ($this->disableFrontendHelper->getConfigValue() === 1) { | ||
// Redirect to admin. | ||
$controller = $observer->getControllerAction(); | ||
$this->redirect->redirect($controller->getResponse(),$this->helperBackend->getHomePageUrl()); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,34 @@ | ||
## Disable Frontend in Magento 2 | ||
# Disable Frontend in Magento 2 | ||
Disable the frontend in Magento 2 for using only the Admin and the API routes. | ||
|
||
#### 1 - Installation Disable Frontend | ||
This was forked from [abelbm/magento2-disable-frontend](https://github.com/abelbm/magento2-disable-frontend) | ||
|
||
##### Manual Installation | ||
## 1. Install Disable Frontend | ||
|
||
### Manual Installation | ||
|
||
Install Disable Frontend for Magento2 | ||
* Download the extension | ||
* Unzip the file | ||
* Create a folder {Magento root}/app/code/Abelbm/DisableFrontend | ||
* Create a folder {Magento root}/app/code/FocusriteNovation/DisableFrontend | ||
* Copy the content from the unzip folder | ||
|
||
### Using Composer | ||
|
||
##### Using Composer | ||
|
||
``` | ||
composer require abelbm/magento2-disablefrontend | ||
```bash | ||
$ composer require focusrite-novation/magento2-disablefrontend | ||
``` | ||
|
||
#### 2 - Enable Disable Frontend | ||
## 2. Enable Disable Frontend | ||
|
||
* php bin/magento module:enable Abelbm_DisableFrontend | ||
* php bin/magento setup:upgrade | ||
* php bin/magento cache:flush | ||
* php bin/magento setup:di:compile | ||
```bash | ||
$ php bin/magento module:enable FocusriteNovation_DisableFrontend | ||
$ php bin/magento setup:upgrade | ||
$ php bin/magento cache:flush | ||
$ php bin/magento setup:di:compile | ||
``` | ||
|
||
#### 3 - Change the frontend redirect | ||
## 3. Change the frontend redirect | ||
|
||
Stores > Configuration > Advanced > Admin > Disable Frontend | ||
Stores > Configuration > Advanced > Admin > Disable Frontend | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"name": "abelbm/magento2-disablefrontend", | ||
"name": "focusrite-novation/magento2-disablefrontend", | ||
"description": "Disable Frontend in Magento 2.", | ||
"keywords": [ | ||
"magento 2", | ||
|
@@ -22,14 +22,20 @@ | |
"email": "[email protected]", | ||
"homepage": "http://abelbolanos.blogspot.com/", | ||
"role": "Developer" | ||
}, | ||
{ | ||
"name": "Sophie Shanahan-Kluth", | ||
"email": "[email protected]", | ||
"homepage": "https://focusrite.com/", | ||
"role": "Lead developer" | ||
} | ||
], | ||
"autoload": { | ||
"files": [ | ||
"registration.php" | ||
], | ||
"psr-4": { | ||
"Abelbm\\DisableFrontend\\": "" | ||
"FocusriteNovation\\DisableFrontend\\": "" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<?xml version="1.0"?> | ||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd"> | ||
<event name="controller_action_predispatch"> | ||
<observer name="disable_frontend_observer" instance="Abelbm\DisableFrontend\Observer\DisableFrontend"/> | ||
<observer name="disable_frontend_observer" instance="FocusriteNovation\DisableFrontend\Observer\DisableFrontend"/> | ||
</event> | ||
</config> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters