We will be off from 27/1 (Monday) to 31/1 (Friday) (GMT +7) for our Tet Holiday (Lunar New Year) in our country

Commit bc985ffd authored by alessio's avatar alessio

PW-1459 Use different url for backend/frontend on getOrigin()

parent 483affba
...@@ -126,6 +126,12 @@ class Data extends AbstractHelper ...@@ -126,6 +126,12 @@ class Data extends AbstractHelper
*/ */
private $config; private $config;
/**
* @var \Magento\Backend\Helper\Data $helperBackend
*/
private $helperBackend;
/** /**
* Data constructor. * Data constructor.
* @param \Magento\Framework\App\Helper\Context $context * @param \Magento\Framework\App\Helper\Context $context
...@@ -145,6 +151,9 @@ class Data extends AbstractHelper ...@@ -145,6 +151,9 @@ class Data extends AbstractHelper
* @param \Magento\Framework\App\CacheInterface $cache * @param \Magento\Framework\App\CacheInterface $cache
* @param \Adyen\Payment\Model\Billing\AgreementFactory $billingAgreementFactory * @param \Adyen\Payment\Model\Billing\AgreementFactory $billingAgreementFactory
* @param \Adyen\Payment\Model\ResourceModel\Billing\Agreement $agreementResourceModel * @param \Adyen\Payment\Model\ResourceModel\Billing\Agreement $agreementResourceModel
* @param \Magento\Framework\Locale\ResolverInterface $localeResolver
* @param \Magento\Framework\App\Config\ScopeConfigInterface $config
* @param \Magento\Backend\Helper\Data $helperBackend
*/ */
public function __construct( public function __construct(
\Magento\Framework\App\Helper\Context $context, \Magento\Framework\App\Helper\Context $context,
...@@ -165,7 +174,8 @@ class Data extends AbstractHelper ...@@ -165,7 +174,8 @@ class Data extends AbstractHelper
\Adyen\Payment\Model\Billing\AgreementFactory $billingAgreementFactory, \Adyen\Payment\Model\Billing\AgreementFactory $billingAgreementFactory,
\Adyen\Payment\Model\ResourceModel\Billing\Agreement $agreementResourceModel, \Adyen\Payment\Model\ResourceModel\Billing\Agreement $agreementResourceModel,
\Magento\Framework\Locale\ResolverInterface $localeResolver, \Magento\Framework\Locale\ResolverInterface $localeResolver,
\Magento\Framework\App\Config\ScopeConfigInterface $config \Magento\Framework\App\Config\ScopeConfigInterface $config,
\Magento\Backend\Helper\Data $helperBackend
) { ) {
parent::__construct($context); parent::__construct($context);
$this->_encryptor = $encryptor; $this->_encryptor = $encryptor;
...@@ -186,6 +196,7 @@ class Data extends AbstractHelper ...@@ -186,6 +196,7 @@ class Data extends AbstractHelper
$this->agreementResourceModel = $agreementResourceModel; $this->agreementResourceModel = $agreementResourceModel;
$this->localeResolver = $localeResolver; $this->localeResolver = $localeResolver;
$this->config = $config; $this->config = $config;
$this->helperBackend = $helperBackend;
} }
/** /**
...@@ -1477,7 +1488,12 @@ class Data extends AbstractHelper ...@@ -1477,7 +1488,12 @@ class Data extends AbstractHelper
* @return string * @return string
*/ */
public function getOrigin() { public function getOrigin() {
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$state = $objectManager->get('Magento\Framework\App\State');
$baseUrl = $this->storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_WEB); $baseUrl = $this->storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_WEB);
if ('adminhtml' === $state->getAreaCode()) {
$baseUrl = $this->helperBackend->getHomePageUrl();
}
$parsed = parse_url($baseUrl); $parsed = parse_url($baseUrl);
$origin = $parsed['scheme'] . "://" . $parsed['host']; $origin = $parsed['scheme'] . "://" . $parsed['host'];
if (!empty($parsed['port'])) { if (!empty($parsed['port'])) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment