Ejemplo n.º 1
0
 /**
  * To configure smtp settings for session right before sending message on windows server
  *
  * @param \Magento\Framework\Mail\TransportInterface $subject
  * @return void
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function beforeSendMessage(\Magento\Framework\Mail\TransportInterface $subject)
 {
     if ($this->osInfo->isWindows()) {
         ini_set('SMTP', $this->config->getValue(self::XML_SMTP_HOST));
         ini_set('smtp_port', $this->config->getValue(self::XML_SMTP_PORT));
     }
 }
 public function testDelete()
 {
     $this->designConfig->expects($this->exactly(2))->method('getExtensionAttributes')->willReturn($this->designExtension);
     $this->designExtension->expects($this->once())->method('getDesignConfigData')->willReturn([$this->designConfigData]);
     $this->configStorage->expects($this->once())->method('delete')->with($this->designConfig);
     $this->reinitableConfig->expects($this->once())->method('reinit');
     $this->indexerRegistry->expects($this->once())->method('get')->with(Config::DESIGN_CONFIG_GRID_INDEXER_ID)->willReturn($this->indexer);
     $this->indexer->expects($this->once())->method('reindexAll');
     $this->assertSame($this->designConfig, $this->repository->delete($this->designConfig));
 }
 /**
  * @inheritDoc
  */
 public function delete(DesignConfigInterface $designConfig)
 {
     if (!($designConfig->getExtensionAttributes() && $designConfig->getExtensionAttributes()->getDesignConfigData())) {
         throw new LocalizedException(__('Can not save empty config'));
     }
     $this->configStorage->delete($designConfig);
     $this->reinitableConfig->reinit();
     $this->reindexGrid();
     return $designConfig;
 }
Ejemplo n.º 4
0
 /**
  * Saves currency symbol to config
  *
  * @param  $symbols array
  * @return $this
  */
 public function setCurrencySymbolsData($symbols = [])
 {
     foreach ($this->getCurrencySymbolsData() as $code => $values) {
         if (isset($symbols[$code])) {
             if ($symbols[$code] == $values['parentSymbol'] || empty($symbols[$code])) {
                 unset($symbols[$code]);
             }
         }
     }
     if ($symbols) {
         $value['options']['fields']['customsymbol']['value'] = serialize($symbols);
     } else {
         $value['options']['fields']['customsymbol']['inherit'] = 1;
     }
     $this->_configFactory->create()->setSection(self::CONFIG_SECTION)->setWebsite(null)->setStore(null)->setGroups($value)->save();
     $this->_eventManager->dispatch('admin_system_config_changed_section_currency_before_reinit', ['website' => $this->_websiteId, 'store' => $this->_storeId]);
     // reinit configuration
     $this->_coreConfig->reinit();
     $this->_storeManager->reinitStores();
     $this->clearCache();
     //Reset symbols cache since new data is added
     $this->_symbolsData = [];
     $this->_eventManager->dispatch('admin_system_config_changed_section_currency', ['website' => $this->_websiteId, 'store' => $this->_storeId]);
     return $this;
 }
 /**
  * Save api credentioals.
  *
  * @param $apiUser
  * @param $apiPass
  *
  * @return bool
  */
 public function saveApiCreds($apiUser, $apiPass)
 {
     $this->helper->saveConfigData(Config::XML_PATH_CONNECTOR_API_ENABLED, '1', 'default', 0);
     $this->helper->saveConfigData(Config::XML_PATH_CONNECTOR_API_USERNAME, $apiUser, 'default', 0);
     $this->helper->saveConfigData(Config::XML_PATH_CONNECTOR_API_PASSWORD, $apiPass, 'default', 0);
     //Clear config cache
     $this->config->reinit();
     return true;
 }
 /**
  * Filter config values.
  *
  * @param Converter $subject
  * @param array $nodes
  * @return array
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function afterConvert(Converter $subject, $nodes)
 {
     if (empty($nodes)) {
         return $nodes;
     }
     $useInsecure = $this->config->getValue(self::XML_ALLOW_INSECURE);
     if ($useInsecure) {
         foreach (array_keys($this->resources) as $resource) {
             list($route, $requestType) = explode("::", $resource);
             if ($result = $this->getNode($route, $requestType, $nodes["routes"])) {
                 if (isset($result[$requestType]['resources'])) {
                     $result[$requestType]['resources'] = ['anonymous' => true];
                     $nodes['routes'][$route] = $result;
                 }
                 if (isset($result[$requestType]['service']['class']) && isset($result[$requestType]['service']['method'])) {
                     $serviceName = $result[$requestType]['service']['class'];
                     $serviceMethod = $result[$requestType]['service']['method'];
                     $nodes['services'][$serviceName]['V1']['methods'][$serviceMethod]['resources'] = ['anonymous'];
                 }
             }
         }
     }
     return $nodes;
 }
 public function testSetCurrencySymbolData()
 {
     $websiteId = 1;
     $groupId = 2;
     $currencies = 'USD,EUR';
     $symbols = [];
     $value['options']['fields']['customsymbol']['inherit'] = 1;
     $this->prepareMocksForGetCurrencySymbolsData($websiteId, $groupId, $currencies);
     /**
      * @var \Magento\Config\Model\Config|\PHPUnit_Framework_MockObject_MockObject
      */
     $configMock = $this->getMock('Magento\\Config\\Model\\Config', ['setSection', 'setWebsite', 'setStore', 'setGroups', 'save'], [], '', false);
     $this->configFactoryMock->expects($this->any())->method('create')->willReturn($configMock);
     $configMock->expects($this->any())->method('setSection')->with(Currencysymbol::CONFIG_SECTION)->willReturnSelf();
     $configMock->expects($this->any())->method('setWebsite')->with(null)->willReturnSelf();
     $configMock->expects($this->any())->method('setStore')->with(null)->willReturnSelf();
     $configMock->expects($this->any())->method('setGroups')->with($value)->willReturnSelf();
     $this->coreConfigMock->expects($this->once())->method('reinit');
     $this->cacheTypeListMock->expects($this->atLeastOnce())->method('invalidate');
     $this->eventManagerMock->expects($this->atLeastOnce())->method('dispatch')->willReturnMap([['admin_system_config_changed_section_currency_before_reinit', null, null], ['admin_system_config_changed_section_currency', null, null]]);
     $this->assertInstanceOf('Magento\\CurrencySymbol\\Model\\System\\Currencysymbol', $this->model->setCurrencySymbolsData($symbols));
 }
Ejemplo n.º 8
0
 /**
  * Retrieve store group name
  *
  * @return string
  */
 public function getFrontendName()
 {
     if (null === $this->_frontendName) {
         $storeGroupName = (string) $this->_config->getValue(Information::XML_PATH_STORE_INFO_NAME, ScopeInterface::SCOPE_STORE, $this);
         $this->_frontendName = !empty($storeGroupName) ? $storeGroupName : $this->getGroup()->getName();
     }
     return $this->_frontendName;
 }
Ejemplo n.º 9
0
 /**
  * Retrieve storegroup name
  *
  * @return string
  */
 public function getFrontendName()
 {
     if (null === $this->_frontendName) {
         $storeGroupName = (string) $this->_config->getValue('general/store_information/name', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $this);
         $this->_frontendName = !empty($storeGroupName) ? $storeGroupName : $this->getGroup()->getName();
     }
     return $this->_frontendName;
 }
Ejemplo n.º 10
0
 /**
  * Get period of time in seconds after which account will be unlocked.
  *
  * @return int
  */
 public function getLockTimeout()
 {
     return (int) $this->storeConfig->getValue('oauth/authentication_lock/timeout');
 }
Ejemplo n.º 11
0
 /**
  * Ensure changes in the configuration, if any, take effect
  *
  * @return void
  */
 protected function _refreshConfig()
 {
     $this->_cache->clean();
     $this->_config->reinit();
 }