diff --git a/CHANGELOG.md b/CHANGELOG.md index e49695b..b317269 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## Unreleased + +### Changed +- Removed legacy page from sidebar nav. + ## 3.1.1 - 2023-10-26 ### Changed diff --git a/src/Inventory.php b/src/Inventory.php index 529ebd2..8eb516f 100644 --- a/src/Inventory.php +++ b/src/Inventory.php @@ -36,11 +36,6 @@ class Inventory extends Plugin */ public static Plugin $plugin; - /** - * @var bool The plugin has its own section. - */ - public bool $hasCpSection = true; - /** * @inheritdoc */ @@ -55,7 +50,7 @@ public function init(): void ]); // Load class services - $inventoryService = Inventory::$plugin->inventoryService; + $inventoryService = self::$plugin->inventoryService; // Set template hook Craft::$app->getView()->hook('getFieldLayouts', [$inventoryService, 'getFieldLayouts']); @@ -66,31 +61,6 @@ public function init(): void // Redirect after plugin install $this->_postInstallRedirect(); - - // Manage whether "Inventory" should appear in the sidebar - $this->_manageSidebarNav(); - } - - // ========================================================================= // - - /** - * Manage whether "Inventory" should appear in the sidebar. - */ - private function _manageSidebarNav(): void - { - // If not a web request, bail - if (!Craft::$app->getRequest()->getIsCpRequest()) { - return; - } - - // Whether a cookie has been set to hide "Inventory" from the sidebar - $hideFromSidebar = Craft::$app->getRequest()->getCookies()->getValue('hide-inventory-from-sidebar'); - - // If cookie exists - if ($hideFromSidebar) { - // Hide "Inventory" from the sidebar - $this->hasCpSection = false; - } } // ========================================================================= // @@ -129,7 +99,7 @@ private function _registerCpRoutes(): void Event::on( UrlManager::class, UrlManager::EVENT_REGISTER_CP_URL_RULES, - function (RegisterUrlRulesEvent $event) { + static function (RegisterUrlRulesEvent $event) { $event->rules['utilities/inventory/'] = ['template' => 'inventory/fields']; } ); diff --git a/src/templates/index.twig b/src/templates/index.twig deleted file mode 100644 index fd2c927..0000000 --- a/src/templates/index.twig +++ /dev/null @@ -1,11 +0,0 @@ -{% extends '_layouts/cp' %} -{% set title = "Field Inventory (has moved)"|t %} - -{% block content %} -

Please note, this tool has moved! As of v3.0, it is now considered a Utility.

-

It can be found at Utilities > Field Inventory

-

Please access the tool via the Utilities page. You may safely remove the sidebar navigation link.

-
- I understand, remove "Inventory" from the sidebar navigation -
-{% endblock %} diff --git a/src/templates/remove-from-sidebar.twig b/src/templates/remove-from-sidebar.twig deleted file mode 100644 index 2bd705a..0000000 --- a/src/templates/remove-from-sidebar.twig +++ /dev/null @@ -1,13 +0,0 @@ -{# Configure the cookie #} -{% set cookie = create({ - 'class': 'yii\\web\\Cookie', - 'name': 'hide-inventory-from-sidebar', - 'value': 'yes', - 'expire': now | date_modify('+10 years').timestamp -}) %} - -{# Set the cookie #} -{% do craft.app.response.cookies.add(cookie) %} - -{# Redirect to utility page #} -{% redirect cpUrl('utilities/inventory?welcome=1') %}