Example #1
0
 /**
  * {@inheritdoc}
  */
 public function getBaseUrl($type = 'link', $secure = null)
 {
     $pluginInfo = $this->pluginList->getNext($this->subjectType, 'getBaseUrl');
     if (!$pluginInfo) {
         return parent::getBaseUrl($type, $secure);
     } else {
         return $this->___callPlugins('getBaseUrl', func_get_args(), $pluginInfo);
     }
 }
Example #2
0
 /**
  * Substitute placeholders {{placeholder_name}} with their values in XML string
  *
  * @param string $xmlString
  * @return string
  */
 protected function _substitutePlaceholders($xmlString)
 {
     if ($this->_subst === null) {
         $placeholders = ['baseUrl' => $this->_store->getBaseUrl(), 'baseSecureUrl' => $this->_store->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_LINK, true)];
         $this->_subst = [];
         foreach ($placeholders as $key => $value) {
             $this->_subst['from'][] = '{{' . $key . '}}';
             $this->_subst['to'][] = $value;
         }
     }
     return str_replace($this->_subst['from'], $this->_subst['to'], $xmlString);
 }
 public function getBaseUrl($type = UrlInterface::URL_TYPE_LINK, $secure = null)
 {
     $cacheKey = $type . '/' . (is_null($secure) ? 'null' : ($secure ? 'true' : 'false'));
     if (!isset($this->_baseUrlCache[$cacheKey])) {
         if ($this->isDeveloper) {
             $dbBaseUrl = $this->_config->getValue(Store::XML_PATH_UNSECURE_BASE_URL, ScopeInterface::SCOPE_STORE);
             $baseUrl = parent::getBaseUrl($type, $secure);
             $host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : parse_url(trim($dbBaseUrl), PHP_URL_HOST);
             $url = str_replace($dbBaseUrl, "http://{$host}/", $baseUrl);
             $this->_baseUrlCache[$cacheKey] = $url;
         }
     }
     return parent::getBaseUrl($type, $secure);
 }
Example #4
0
 /**
  * Isolation is enabled, as we pollute config with rewrite values
  *
  * @param string $type
  * @param bool $useCustomEntryPoint
  * @param bool $useStoreCode
  * @param string $expected
  * @dataProvider getBaseUrlForCustomEntryPointDataProvider
  * @magentoAppIsolation enabled
  */
 public function testGetBaseUrlForCustomEntryPoint($type, $useCustomEntryPoint, $useStoreCode, $expected)
 {
     /* config operations require store to be loaded */
     $this->model->load('default');
     \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Framework\\App\\Config\\MutableScopeConfigInterface')->setValue(Store::XML_PATH_USE_REWRITES, false, ScopeInterface::SCOPE_STORE);
     \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Framework\\App\\Config\\MutableScopeConfigInterface')->setValue(Store::XML_PATH_STORE_IN_URL, $useStoreCode, ScopeInterface::SCOPE_STORE);
     // emulate custom entry point
     $_SERVER['SCRIPT_FILENAME'] = 'custom_entry.php';
     if ($useCustomEntryPoint) {
         $property = new \ReflectionProperty($this->model, '_isCustomEntryPoint');
         $property->setAccessible(true);
         $property->setValue($this->model, $useCustomEntryPoint);
     }
     $actual = $this->model->getBaseUrl($type);
     $this->assertEquals($expected, $actual);
 }
 /**
  * @param \Magento\Store\Model\Store $store
  * @return \Magento\Store\Api\Data\StoreConfigInterface
  */
 protected function getStoreConfig($store)
 {
     /** @var \Magento\Store\Model\Data\StoreConfig $storeConfig */
     $storeConfig = $this->storeConfigFactory->create();
     $storeConfig->setId($store->getId())->setCode($store->getCode())->setWebsiteId($store->getWebsiteId());
     foreach ($this->configPaths as $methodName => $configPath) {
         $configValue = $this->scopeConfig->getValue($configPath, \Magento\Store\Model\ScopeInterface::SCOPE_STORES, $store->getCode());
         $storeConfig->{$methodName}($configValue);
     }
     $storeConfig->setBaseUrl($store->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_WEB, false));
     $storeConfig->setSecureBaseUrl($store->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_WEB, true));
     $storeConfig->setBaseLinkUrl($store->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_LINK, false));
     $storeConfig->setSecureBaseLinkUrl($store->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_LINK, true));
     $storeConfig->setBaseStaticUrl($store->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_STATIC, false));
     $storeConfig->setSecureBaseStaticUrl($store->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_STATIC, true));
     $storeConfig->setBaseMediaUrl($store->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA, false));
     $storeConfig->setSecureBaseMediaUrl($store->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA, true));
     return $storeConfig;
 }
Example #6
0
 /**
  * @param Store $store
  * @return \NostoAccount
  */
 public function build(Store $store)
 {
     $metaData = new \NostoAccount();
     try {
         $metaData->setTitle(implode(' - ', [$store->getWebsite()->getName(), $store->getGroup()->getName(), $store->getName()]));
         $metaData->setName(substr(sha1(rand()), 0, 8));
         $metaData->setFrontPageUrl(\NostoHttpRequest::replaceQueryParamInUrl('___store', $store->getCode(), $store->getBaseUrl(UrlInterface::URL_TYPE_WEB)));
         $metaData->setCurrency(new \NostoCurrencyCode($store->getBaseCurrencyCode()));
         $lang = substr($store->getConfig('general/locale/code'), 0, 2);
         $metaData->setLanguage(new \NostoLanguageCode($lang));
         $lang = substr($this->_localeResolver->getLocale(), 0, 2);
         $metaData->setOwnerLanguage(new \NostoLanguageCode($lang));
         $owner = $this->_accountOwnerMetaBuilder->build();
         $metaData->setOwner($owner);
         $billing = $this->_accountBillingMetaBuilder->build($store);
         $metaData->setBilling($billing);
     } catch (\NostoException $e) {
         $this->_logger->error($e, ['exception' => $e]);
     }
     return $metaData;
 }