From b5c254d0418cbe7f015cee6e90b80dc49dd4691b Mon Sep 17 00:00:00 2001 From: Sophie Shanahan-Kluth Date: Thu, 18 Jun 2020 14:37:43 +0100 Subject: [PATCH] Rename to FocusriteNovation and some tidy ups. --- .gitignore | 3 ++- Helper/Data.php | 4 +-- Model/Config/Source/Custom.php | 7 ++--- Observer/DisableFrontend.php | 49 +++++++++++++++++++++------------- README.md | 33 ++++++++++++----------- composer.json | 10 +++++-- etc/adminhtml/system.xml | 9 ++++--- etc/frontend/events.xml | 2 +- etc/module.xml | 2 +- registration.php | 2 +- 10 files changed, 74 insertions(+), 47 deletions(-) diff --git a/.gitignore b/.gitignore index c3adeeb..f972670 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -/nbproject/* \ No newline at end of file +/nbproject/* +/vendor/ \ No newline at end of file diff --git a/Helper/Data.php b/Helper/Data.php index 9fa45d3..28e38a4 100644 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -1,6 +1,6 @@ scopeConfig->getValue( - 'admin/disable_frontend/show_as_frontend', ScopeInterface::SCOPE_WEBSITE + 'admin/disable_frontend/show_frontend_as', ScopeInterface::SCOPE_WEBSITE ); } } \ No newline at end of file diff --git a/Model/Config/Source/Custom.php b/Model/Config/Source/Custom.php index 3520490..9d53d87 100644 --- a/Model/Config/Source/Custom.php +++ b/Model/Config/Source/Custom.php @@ -1,5 +1,5 @@ 0, 'label' => __('Blank Page')], - ['value' => 1, 'label' => __('Admin')], + ['value' => 0, 'label' => __('Blank page')], + ['value' => 1, 'label' => __('Admin login')], + ['value' => 2, 'label' => __('Specific URL')], ]; } } \ No newline at end of file diff --git a/Observer/DisableFrontend.php b/Observer/DisableFrontend.php index 2712381..b29e2d5 100644 --- a/Observer/DisableFrontend.php +++ b/Observer/DisableFrontend.php @@ -1,18 +1,35 @@ _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 - * @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()); } diff --git a/README.md b/README.md index 3814380..9af0b46 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/composer.json b/composer.json index 4ed1074..7da9ff6 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "abelbm/magento2-disablefrontend", + "name": "focusrite-novation/magento2-disablefrontend", "description": "Disable Frontend in Magento 2.", "keywords": [ "magento 2", @@ -22,6 +22,12 @@ "email": "abelbmartinez@gmail.com", "homepage": "http://abelbolanos.blogspot.com/", "role": "Developer" + }, + { + "name": "Sophie Shanahan-Kluth", + "email": "sophie.sk@focusrite.com", + "homepage": "https://focusrite.com/", + "role": "Lead developer" } ], "autoload": { @@ -29,7 +35,7 @@ "registration.php" ], "psr-4": { - "Abelbm\\DisableFrontend\\": "" + "FocusriteNovation\\DisableFrontend\\": "" } } } diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index 3b4a401..1ad133b 100644 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -3,10 +3,13 @@
- - + + - Abelbm\DisableFrontend\Model\Config\Source\Custom + FocusriteNovation\DisableFrontend\Model\Config\Source\Custom + + +
diff --git a/etc/frontend/events.xml b/etc/frontend/events.xml index 2ebfa9e..26f5cfd 100644 --- a/etc/frontend/events.xml +++ b/etc/frontend/events.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/etc/module.xml b/etc/module.xml index c387abd..c470e9e 100644 --- a/etc/module.xml +++ b/etc/module.xml @@ -1,6 +1,6 @@ - + diff --git a/registration.php b/registration.php index 82d1d51..ba59784 100644 --- a/registration.php +++ b/registration.php @@ -2,6 +2,6 @@ \Magento\Framework\Component\ComponentRegistrar::register( \Magento\Framework\Component\ComponentRegistrar::MODULE, - 'Abelbm_DisableFrontend', + 'FocusriteNovation_DisableFrontend', __DIR__ ); \ No newline at end of file