diff --git a/src/Block/Inspector.php b/src/Block/Inspector.php
index 6c3b3c05..d833aa5a 100644
--- a/src/Block/Inspector.php
+++ b/src/Block/Inspector.php
@@ -9,6 +9,8 @@
use Magento\Framework\App\State;
use Magento\Framework\View\Element\Template;
use Magento\Framework\View\Element\Template\Context;
+use Magento\Store\Model\ScopeInterface;
+use OpenForgeProject\MageForge\Model\Config\Inspector as InspectorConfig;
/**
* Block for MageForge Inspector
@@ -17,9 +19,6 @@
*/
class Inspector extends Template
{
- private const XML_PATH_INSPECTOR_ENABLED = 'dev/mageforge_inspector/enabled';
- private const XML_PATH_SHOW_BUTTON_LABELS = 'mageforge/inspector/show_button_labels';
-
/**
* @param Context $context
* @param State $state
@@ -51,7 +50,7 @@ public function shouldRender(): bool
}
// Check if inspector is enabled in configuration
- if (!$this->scopeConfig->isSetFlag(self::XML_PATH_INSPECTOR_ENABLED)) {
+ if (!$this->scopeConfig->isSetFlag(InspectorConfig::XML_PATH_ENABLED, ScopeInterface::SCOPE_STORE)) {
return false;
}
@@ -110,7 +109,10 @@ public function getToolbarJsUrl(): string
*/
public function getShowButtonLabels(): bool
{
- $value = $this->scopeConfig->getValue(self::XML_PATH_SHOW_BUTTON_LABELS);
+ $value = $this->scopeConfig->getValue(
+ InspectorConfig::XML_PATH_SHOW_BUTTON_LABELS,
+ ScopeInterface::SCOPE_STORE
+ );
// Default to true when not explicitly set to '0'
return !is_string($value) || $value !== '0';
}
@@ -122,8 +124,19 @@ public function getShowButtonLabels(): bool
*/
public function getTheme(): string
{
- $value = $this->scopeConfig->getValue('mageforge/inspector/theme');
- return is_string($value) && $value !== '' ? $value : 'dark';
+ $value = $this->scopeConfig->getValue(InspectorConfig::XML_PATH_THEME, ScopeInterface::SCOPE_STORE);
+ return is_string($value) && $value !== '' ? $value : InspectorConfig::DEFAULT_THEME;
+ }
+
+ /**
+ * Get configured toolbar position
+ *
+ * @return string
+ */
+ public function getPosition(): string
+ {
+ $value = $this->scopeConfig->getValue(InspectorConfig::XML_PATH_POSITION, ScopeInterface::SCOPE_STORE);
+ return is_string($value) && $value !== '' ? $value : InspectorConfig::DEFAULT_POSITION;
}
/**
diff --git a/src/Console/Command/Dev/InspectorCommand.php b/src/Console/Command/Dev/InspectorCommand.php
index 5b1e4f30..d531fae3 100644
--- a/src/Console/Command/Dev/InspectorCommand.php
+++ b/src/Console/Command/Dev/InspectorCommand.php
@@ -10,6 +10,7 @@
use Magento\Framework\App\State;
use Magento\Framework\Console\Cli;
use OpenForgeProject\MageForge\Console\Command\AbstractCommand;
+use OpenForgeProject\MageForge\Model\Config\Inspector as InspectorConfig;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
@@ -19,7 +20,6 @@
*/
class InspectorCommand extends AbstractCommand
{
- private const XML_PATH_INSPECTOR_ENABLED = 'dev/mageforge_inspector/enabled';
private const ARGUMENT_ACTION = 'action';
/**
@@ -106,7 +106,7 @@ protected function executeCommand(InputInterface $input, OutputInterface $output
return match ($action) {
'enable' => $this->enableInspector(),
'disable' => $this->disableInspector(),
- 'status' => $this->showStatus(),
+ default => $this->showStatus(),
};
}
@@ -117,7 +117,7 @@ protected function executeCommand(InputInterface $input, OutputInterface $output
*/
private function enableInspector(): int
{
- $this->configWriter->save(self::XML_PATH_INSPECTOR_ENABLED, '1');
+ $this->configWriter->save(InspectorConfig::XML_PATH_ENABLED, '1');
$this->cleanCache();
$this->io->success('MageForge Inspector has been enabled!');
@@ -142,7 +142,7 @@ private function enableInspector(): int
*/
private function disableInspector(): int
{
- $this->configWriter->save(self::XML_PATH_INSPECTOR_ENABLED, '0');
+ $this->configWriter->save(InspectorConfig::XML_PATH_ENABLED, '0');
$this->cleanCache();
$this->io->success('MageForge Inspector has been disabled.');
@@ -193,11 +193,7 @@ private function showStatus(): int
*/
private function isDeveloperMode(): bool
{
- try {
- return $this->state->getMode() === State::MODE_DEVELOPER;
- } catch (\Exception $e) {
- return false;
- }
+ return $this->state->getMode() === State::MODE_DEVELOPER;
}
/**
@@ -207,11 +203,7 @@ private function isDeveloperMode(): bool
*/
private function isInspectorEnabled(): bool
{
- try {
- return $this->scopeConfig->isSetFlag(self::XML_PATH_INSPECTOR_ENABLED);
- } catch (\Exception $e) {
- return false;
- }
+ return $this->scopeConfig->isSetFlag(InspectorConfig::XML_PATH_ENABLED);
}
/**
diff --git a/src/Model/Config/Inspector.php b/src/Model/Config/Inspector.php
new file mode 100644
index 00000000..d1aab7d1
--- /dev/null
+++ b/src/Model/Config/Inspector.php
@@ -0,0 +1,15 @@
+>
+ */
+ public function toOptionArray(): array
+ {
+ return [
+ ['value' => 'bottom-left', 'label' => (string) __('Bottom Left')],
+ ['value' => 'bottom-right', 'label' => (string) __('Bottom Right')],
+ ['value' => 'top-left', 'label' => (string) __('Top Left')],
+ ['value' => 'top-right', 'label' => (string) __('Top Right')],
+ ];
+ }
+}
diff --git a/src/Model/TemplateEngine/Plugin/InspectorHints.php b/src/Model/TemplateEngine/Plugin/InspectorHints.php
index cbe07ee9..b2c6b6af 100644
--- a/src/Model/TemplateEngine/Plugin/InspectorHints.php
+++ b/src/Model/TemplateEngine/Plugin/InspectorHints.php
@@ -11,6 +11,7 @@
use Magento\Framework\View\TemplateEngineInterface;
use Magento\Store\Model\ScopeInterface;
use Magento\Store\Model\StoreManagerInterface;
+use OpenForgeProject\MageForge\Model\Config\Inspector as InspectorConfig;
use OpenForgeProject\MageForge\Model\TemplateEngine\Decorator\InspectorHintsFactory;
/**
@@ -20,8 +21,6 @@
*/
class InspectorHints
{
- private const XML_PATH_INSPECTOR_ENABLED = 'dev/mageforge_inspector/enabled';
-
/**
* @param ScopeConfigInterface $scopeConfig
* @param StoreManagerInterface $storeManager
@@ -57,7 +56,12 @@ public function afterCreate(
// Check if inspector is enabled in configuration
$storeCode = $this->storeManager->getStore()->getCode();
- if (!$this->scopeConfig->isSetFlag(self::XML_PATH_INSPECTOR_ENABLED, ScopeInterface::SCOPE_STORE, $storeCode)) {
+ $isEnabled = $this->scopeConfig->isSetFlag(
+ InspectorConfig::XML_PATH_ENABLED,
+ ScopeInterface::SCOPE_STORE,
+ $storeCode
+ );
+ if (!$isEnabled) {
return $invocationResult;
}
diff --git a/src/etc/adminhtml/system.xml b/src/etc/adminhtml/system.xml
index 4de1c0d1..697ba9dd 100644
--- a/src/etc/adminhtml/system.xml
+++ b/src/etc/adminhtml/system.xml
@@ -10,24 +10,30 @@