diff --git a/Api/Data/DomainInterface.php b/Api/Data/DomainInterface.php new file mode 100644 index 0000000..7b48f44 --- /dev/null +++ b/Api/Data/DomainInterface.php @@ -0,0 +1,16 @@ +getServer('HTTP_X_ORIGINAL_HOST') ?: $this->getServer('HTTP_HOST'); - return stripos($ngrokDomain, self::NGROK_DOMAIN) !== false ? $ngrokDomain : false; + $configuredNgrokDomain = $this->config->isCustomDomainEnabled() ? + $this->config->getCustomDomain() : + $this->config->getDomain(); + + return stripos($ngrokDomain, $configuredNgrokDomain) !== false ? $ngrokDomain : false; } /** diff --git a/Model/Config.php b/Model/Config.php new file mode 100644 index 0000000..8db8e6c --- /dev/null +++ b/Model/Config.php @@ -0,0 +1,49 @@ +scopeConfig->isSetFlag( + self::XML_IS_CUSTOM_DOMAIN + ); + } + + /** + * @return string + */ + public function getDomain(): string + { + return (string)$this->scopeConfig->getValue( + self::XML_DOMAIN + ); + } + + /** + * @return string + */ + public function getCustomDomain(): string + { + return (string)$this->scopeConfig->getValue( + self::XML_CUSTOM_DOMAIN + ); + } +} \ No newline at end of file diff --git a/Model/Config/Source/Domain.php b/Model/Config/Source/Domain.php new file mode 100644 index 0000000..a020b2d --- /dev/null +++ b/Model/Config/Source/Domain.php @@ -0,0 +1,33 @@ + DomainInterface::NGROK_IO, 'value' => DomainInterface::NGROK_IO + ], + [ + 'label' => DomainInterface::NGROK_APP, 'value' => DomainInterface::NGROK_APP + ], + [ + 'label' => DomainInterface::NGROK_DEV, 'value' => DomainInterface::NGROK_DEV + ], + [ + 'label' => DomainInterface::NGROK_FREE_APP, 'value' => DomainInterface::NGROK_FREE_APP + ], + [ + 'label' => DomainInterface::NGROK_FREE_DEV, 'value' => DomainInterface::NGROK_FREE_DEV + ] + ]; + } +} \ No newline at end of file diff --git a/etc/acl.xml b/etc/acl.xml new file mode 100644 index 0000000..5d870a8 --- /dev/null +++ b/etc/acl.xml @@ -0,0 +1,11 @@ + + + + + + + + + + diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml new file mode 100644 index 0000000..f047472 --- /dev/null +++ b/etc/adminhtml/system.xml @@ -0,0 +1,52 @@ + + + + + + +
+ separator-top + + ngrok_tab + Shkoliar_Ngrok::config + + + + + required-entry + Shkoliar\Ngrok\Model\Config\Source\Domain + + + required-entry + Magento\Config\Model\Config\Source\Yesno + + + + + 1 + + + +
+
+
diff --git a/etc/config.xml b/etc/config.xml new file mode 100644 index 0000000..58b2b90 --- /dev/null +++ b/etc/config.xml @@ -0,0 +1,12 @@ + + + + + + 0 + .ngrok-free.app + + + + diff --git a/etc/module.xml b/etc/module.xml index 94185a5..99ca182 100644 --- a/etc/module.xml +++ b/etc/module.xml @@ -9,5 +9,10 @@ --> - + + + + + + \ No newline at end of file