当前位置: 首页>>代码示例>>PHP>>正文


PHP Config\ScopeConfigInterface类代码示例

本文整理汇总了PHP中Magento\Framework\App\Config\ScopeConfigInterface的典型用法代码示例。如果您正苦于以下问题:PHP ScopeConfigInterface类的具体用法?PHP ScopeConfigInterface怎么用?PHP ScopeConfigInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ScopeConfigInterface类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 /**
  * ItemFactory constructor.
  *
  * @param ObjectManagerInterface $objectManager    The Object Manager
  * @param UrlInterface           $urlBuilder       The Url Builder
  * @param ScopeConfigInterface   $scopeConfig      The Scope Config
  * @param CategoryResource       $categoryResource Category Resource Model
  */
 public function __construct(ObjectManagerInterface $objectManager, UrlInterface $urlBuilder, ScopeConfigInterface $scopeConfig, CategoryResource $categoryResource)
 {
     parent::__construct($objectManager);
     $this->urlBuilder = $urlBuilder;
     $this->categoryUrlSuffix = $scopeConfig->getValue(self::XML_PATH_CATEGORY_URL_SUFFIX);
     $this->categoryResource = $categoryResource;
 }
开发者ID:smile-sa,项目名称:elasticsuite,代码行数:15,代码来源:ItemFactory.php

示例2: testAfterDelete

 public function testAfterDelete()
 {
     $this->configMock->expects($this->any())->method('getValue')->willReturnMap([[Theme::XML_PATH_INVALID_CACHES, ScopeInterface::SCOPE_STORE, null, ['block_html' => 1, 'layout' => 1, 'translate' => 1]], [null, ScopeConfigInterface::SCOPE_TYPE_DEFAULT, null, 'old_value']]);
     $this->cacheTypeListMock->expects($this->exactly(2))->method('invalidate');
     $this->model->setValue('some_value');
     $this->assertSame($this->model, $this->model->afterDelete());
 }
开发者ID:rafaelstz,项目名称:magento2,代码行数:7,代码来源:ThemeTest.php

示例3: scheduledUpdateCurrencyRates

 /**
  * @param mixed $schedule
  * @return void
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function scheduledUpdateCurrencyRates($schedule)
 {
     $importWarnings = [];
     if (!$this->_scopeConfig->getValue(self::IMPORT_ENABLE, \Magento\Store\Model\ScopeInterface::SCOPE_STORE) || !$this->_scopeConfig->getValue(self::CRON_STRING_PATH, \Magento\Store\Model\ScopeInterface::SCOPE_STORE)) {
         return;
     }
     $errors = [];
     $rates = [];
     $service = $this->_scopeConfig->getValue(self::IMPORT_SERVICE, \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
     if ($service) {
         try {
             $importModel = $this->_importFactory->create($service);
             $rates = $importModel->fetchRates();
             $errors = $importModel->getMessages();
         } catch (\Exception $e) {
             $importWarnings[] = __('FATAL ERROR:') . ' ' . __('We can\'t initialize the import model.');
         }
     } else {
         $importWarnings[] = __('FATAL ERROR:') . ' ' . __('Please specify the correct Import Service.');
     }
     if (sizeof($errors) > 0) {
         foreach ($errors as $error) {
             $importWarnings[] = __('WARNING:') . ' ' . $error;
         }
     }
     if (sizeof($importWarnings) == 0) {
         $this->_currencyFactory->create()->saveRates($rates);
     } else {
         $this->inlineTranslation->suspend();
         $this->_transportBuilder->setTemplateIdentifier($this->_scopeConfig->getValue(self::XML_PATH_ERROR_TEMPLATE, \Magento\Store\Model\ScopeInterface::SCOPE_STORE))->setTemplateOptions(['area' => \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE, 'store' => \Magento\Store\Model\Store::DEFAULT_STORE_ID])->setTemplateVars(['warnings' => join("\n", $importWarnings)])->setFrom($this->_scopeConfig->getValue(self::XML_PATH_ERROR_IDENTITY, \Magento\Store\Model\ScopeInterface::SCOPE_STORE))->addTo($this->_scopeConfig->getValue(self::XML_PATH_ERROR_RECIPIENT, \Magento\Store\Model\ScopeInterface::SCOPE_STORE));
         $transport = $this->_transportBuilder->getTransport();
         $transport->sendMessage();
         $this->inlineTranslation->resume();
     }
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:40,代码来源:Observer.php

示例4: isHostBackend

 /**
  * Return whether the host from request is the backend host
  * @return bool
  */
 public function isHostBackend()
 {
     $backendUrl = $this->configInterface->getValue(Store::XML_PATH_UNSECURE_BASE_URL, ScopeInterface::SCOPE_STORE);
     $backendHost = parse_url(trim($backendUrl), PHP_URL_HOST);
     $host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '';
     return (strcasecmp($backendHost, $host) === 0);
 }
开发者ID:razbakov,项目名称:magento2,代码行数:11,代码来源:FrontNameResolver.php

示例5: scheduledGenerateSitemaps

 /**
  * Generate sitemaps
  *
  * @return void
  * @SuppressWarnings(PHPMD.UnusedLocalVariable)
  */
 public function scheduledGenerateSitemaps()
 {
     $errors = [];
     // check if scheduled generation enabled
     if (!$this->_scopeConfig->isSetFlag(self::XML_PATH_GENERATION_ENABLED, \Magento\Store\Model\ScopeInterface::SCOPE_STORE)) {
         return;
     }
     $collection = $this->_collectionFactory->create();
     /* @var $collection \Magento\Sitemap\Model\ResourceModel\Sitemap\Collection */
     foreach ($collection as $sitemap) {
         /* @var $sitemap \Magento\Sitemap\Model\Sitemap */
         try {
             $sitemap->generateXml();
         } catch (\Exception $e) {
             $errors[] = $e->getMessage();
         }
     }
     if ($errors && $this->_scopeConfig->getValue(self::XML_PATH_ERROR_RECIPIENT, \Magento\Store\Model\ScopeInterface::SCOPE_STORE)) {
         $translate = $this->_translateModel->getTranslateInline();
         $this->_translateModel->setTranslateInline(false);
         $this->_transportBuilder->setTemplateIdentifier($this->_scopeConfig->getValue(self::XML_PATH_ERROR_TEMPLATE, \Magento\Store\Model\ScopeInterface::SCOPE_STORE))->setTemplateOptions(['area' => \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE, 'store' => \Magento\Store\Model\Store::DEFAULT_STORE_ID])->setTemplateVars(['warnings' => join("\n", $errors)])->setFrom($this->_scopeConfig->getValue(self::XML_PATH_ERROR_IDENTITY, \Magento\Store\Model\ScopeInterface::SCOPE_STORE))->addTo($this->_scopeConfig->getValue(self::XML_PATH_ERROR_RECIPIENT, \Magento\Store\Model\ScopeInterface::SCOPE_STORE));
         $transport = $this->_transportBuilder->getTransport();
         $transport->sendMessage();
         $this->inlineTranslation->resume();
     }
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:32,代码来源:Observer.php

示例6: execute

 /**
  * Create Backup
  *
  * @return $this
  */
 public function execute()
 {
     if (!$this->_scopeConfig->isSetFlag(self::XML_PATH_BACKUP_ENABLED, ScopeInterface::SCOPE_STORE)) {
         return $this;
     }
     if ($this->_scopeConfig->isSetFlag(self::XML_PATH_BACKUP_MAINTENANCE_MODE, ScopeInterface::SCOPE_STORE)) {
         $this->maintenanceMode->set(true);
     }
     $type = $this->_scopeConfig->getValue(self::XML_PATH_BACKUP_TYPE, ScopeInterface::SCOPE_STORE);
     $this->_errors = [];
     try {
         $backupManager = $this->_backupFactory->create($type)->setBackupExtension($this->_backupData->getExtensionByType($type))->setTime(time())->setBackupsDir($this->_backupData->getBackupsDir());
         $this->_coreRegistry->register('backup_manager', $backupManager);
         if ($type != \Magento\Framework\Backup\Factory::TYPE_DB) {
             $backupManager->setRootDir($this->_filesystem->getDirectoryRead(DirectoryList::ROOT)->getAbsolutePath())->addIgnorePaths($this->_backupData->getBackupIgnorePaths());
         }
         $backupManager->create();
         $message = $this->_backupData->getCreateSuccessMessageByType($type);
         $this->_logger->info($message);
     } catch (\Exception $e) {
         $this->_errors[] = $e->getMessage();
         $this->_errors[] = $e->getTrace();
         $this->_logger->info($e->getMessage());
         $this->_logger->critical($e);
     }
     if ($this->_scopeConfig->isSetFlag(self::XML_PATH_BACKUP_MAINTENANCE_MODE, ScopeInterface::SCOPE_STORE)) {
         $this->maintenanceMode->set(false);
     }
     return $this;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:35,代码来源:SystemBackup.php

示例7: sendNotification

 public function sendNotification($data)
 {
     if (!$data) {
         return false;
     }
     $this->inlineTranslation->suspend();
     try {
         $postObject = new \Magento\Framework\DataObject();
         $postObject->setData($data);
         $error = false;
         $storeScope = \Magento\Store\Model\ScopeInterface::SCOPE_STORE;
         /* $from = [
                'name' => '',
                'email' => ''
            ];*/
         $email_template = $this->scopeConfig->getValue('cadou/email/template');
         if (empty($email_template)) {
             $email_template = (string) 'cadou_email_template';
             // this code we have mentioned in the email_templates.xml
         }
         $transport = $this->_transportBuilder->setTemplateIdentifier($email_template)->setTemplateOptions(['area' => \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE, 'store' => $this->storeManager->getDefaultStoreView()->getId()])->setTemplateVars(['data' => $postObject, 'subject' => $data['productname']])->setFrom($this->scopeConfig->getValue('contact/email/sender_email_identity', $storeScope))->addTo($data['email'], isset($data['fullname']) ? $data['fullname'] : $data['name'])->getTransport();
         $transport->sendMessage();
         $this->inlineTranslation->resume();
         /*$this->messageManager->addSuccess(
               __('Thanks for contacting us with your comments and questions. We\'ll respond to you very soon.')
           );*/
         return TRUE;
     } catch (\Exception $e) {
         $this->inlineTranslation->resume();
         $this->messageManager->addError(__('We can\'t process your request right now. Sorry, that\'s all we know.' . $e->getMessage()));
         return FALSE;
     }
 }
开发者ID:alinmiron,项目名称:alin-cadou,代码行数:33,代码来源:Mailer.php

示例8: testAfterGetStateActive

 /**
  * @dataProvider afterGetStateActiveDataProvider
  */
 public function testAfterGetStateActive($scopeConfigMockReturnValue, $result, $assertResult)
 {
     /** @var \Magento\Checkout\Block\Cart\Shipping $subjectMock */
     $subjectMock = $this->getMockBuilder('Magento\\Checkout\\Block\\Cart\\Shipping')->disableOriginalConstructor()->getMock();
     $this->scopeConfigMock->expects($result ? $this->never() : $this->once())->method('getValue')->willReturn($scopeConfigMockReturnValue);
     $this->assertEquals($assertResult, $this->model->afterGetStateActive($subjectMock, $result));
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:10,代码来源:ShippingTest.php

示例9: testShouldBeSecure

 /**
  * @param $unsecureBaseUrl
  * @param $useSecureInAdmin
  * @param $secureBaseUrl
  * @param $expected
  * @dataProvider shouldBeSecureDataProvider
  */
 public function testShouldBeSecure($unsecureBaseUrl, $useSecureInAdmin, $secureBaseUrl, $expected)
 {
     $coreConfigValueMap = [[\Magento\Store\Model\Store::XML_PATH_UNSECURE_BASE_URL, 'default', null, $unsecureBaseUrl], [\Magento\Store\Model\Store::XML_PATH_SECURE_BASE_URL, 'default', null, $secureBaseUrl]];
     $this->coreConfig->expects($this->any())->method('getValue')->will($this->returnValueMap($coreConfigValueMap));
     $this->backendConfig->expects($this->any())->method('isSetFlag')->willReturn($useSecureInAdmin);
     $this->assertEquals($expected, $this->adminPathConfig->shouldBeSecure(''));
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:14,代码来源:AdminPathConfigTest.php

示例10: testAddTrackingNumbersToShipment

 /**
  * @covers \Magento\Shipping\Model\Shipping\LabelGenerator
  * @param array $info
  * @dataProvider labelInfoDataProvider
  */
 public function testAddTrackingNumbersToShipment(array $info)
 {
     $order = $this->getMockBuilder('Magento\\Sales\\Model\\Order')->disableOriginalConstructor()->getMock();
     $order->expects(static::once())->method('getShippingMethod')->with(true)->willReturn($this->getShippingMethodMock());
     /**
      * @var $shipmentMock \Magento\Sales\Model\Order\Shipment|\PHPUnit_Framework_MockObject_MockObject
      */
     $shipmentMock = $this->getMockBuilder('Magento\\Sales\\Model\\Order\\Shipment')->disableOriginalConstructor()->getMock();
     $shipmentMock->expects(static::once())->method('getOrder')->willReturn($order);
     $this->carrierFactory->expects(static::once())->method('create')->with(self::CARRIER_CODE)->willReturn($this->getCarrierMock());
     $labelsMock = $this->getMockBuilder('\\Magento\\Shipping\\Model\\Shipping\\Labels')->disableOriginalConstructor()->getMock();
     $labelsMock->expects(static::once())->method('requestToShipment')->with($shipmentMock)->willReturn($this->getResponseMock($info));
     $this->labelsFactory->expects(static::once())->method('create')->willReturn($labelsMock);
     $this->filesystem->expects(static::once())->method('getDirectoryWrite')->willReturn($this->getMock('Magento\\Framework\\Filesystem\\Directory\\WriteInterface'));
     $this->scopeConfig->expects(static::once())->method('getValue')->with('carriers/' . self::CARRIER_CODE . '/title', ScopeInterface::SCOPE_STORE, null)->willReturn(self::CARRIER_TITLE);
     $this->labelsFactory->expects(static::once())->method('create')->willReturn($labelsMock);
     $trackMock = $this->getMockBuilder('Magento\\Sales\\Model\\Order\\Shipment\\Track')->setMethods(['setNumber', 'setCarrierCode', 'setTitle'])->disableOriginalConstructor()->getMock();
     $i = 0;
     $trackingNumbers = is_array($info['tracking_number']) ? $info['tracking_number'] : [$info['tracking_number']];
     foreach ($trackingNumbers as $trackingNumber) {
         $trackMock->expects(static::at($i++))->method('setNumber')->with($trackingNumber)->willReturnSelf();
         $trackMock->expects(static::at($i++))->method('setCarrierCode')->with(self::CARRIER_CODE)->willReturnSelf();
         $trackMock->expects(static::at($i++))->method('setTitle')->with(self::CARRIER_TITLE)->willReturnSelf();
     }
     $this->trackFactory->expects(static::any())->method('create')->willReturn($trackMock);
     /**
      * @var $requestMock \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject
      */
     $requestMock = $this->getMock('Magento\\Framework\\App\\RequestInterface');
     $this->labelGenerator->create($shipmentMock, $requestMock);
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:36,代码来源:LabelGeneratorTest.php

示例11: _validate

 /**
  * Validate data
  *
  * @return bool
  * @throws Exception
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 protected function _validate()
 {
     $sessionData = $_SESSION[self::VALIDATOR_KEY];
     $validatorData = $this->_getSessionEnvironment();
     if ($this->_scopeConfig->getValue(self::XML_PATH_USE_REMOTE_ADDR, $this->_scopeType) && $sessionData[self::VALIDATOR_REMOTE_ADDR_KEY] != $validatorData[self::VALIDATOR_REMOTE_ADDR_KEY]) {
         throw new Exception('Invalid session ' . self::VALIDATOR_REMOTE_ADDR_KEY . ' value.');
     }
     if ($this->_scopeConfig->getValue(self::XML_PATH_USE_HTTP_VIA, $this->_scopeType) && $sessionData[self::VALIDATOR_HTTP_VIA_KEY] != $validatorData[self::VALIDATOR_HTTP_VIA_KEY]) {
         throw new Exception('Invalid session ' . self::VALIDATOR_HTTP_VIA_KEY . ' value.');
     }
     $httpXForwardedKey = $sessionData[self::VALIDATOR_HTTP_X_FORWARDED_FOR_KEY];
     $validatorXForwarded = $validatorData[self::VALIDATOR_HTTP_X_FORWARDED_FOR_KEY];
     if ($this->_scopeConfig->getValue(self::XML_PATH_USE_X_FORWARDED, $this->_scopeType) && $httpXForwardedKey != $validatorXForwarded) {
         throw new Exception('Invalid session ' . self::VALIDATOR_HTTP_X_FORWARDED_FOR_KEY . ' value.');
     }
     if ($this->_scopeConfig->getValue(self::XML_PATH_USE_USER_AGENT, $this->_scopeType) && $sessionData[self::VALIDATOR_HTTP_USER_AGENT_KEY] != $validatorData[self::VALIDATOR_HTTP_USER_AGENT_KEY]) {
         foreach ($this->_skippedAgentList as $agent) {
             if (preg_match('/' . $agent . '/iu', $validatorData[self::VALIDATOR_HTTP_USER_AGENT_KEY])) {
                 return true;
             }
         }
         throw new Exception('Invalid session ' . self::VALIDATOR_HTTP_USER_AGENT_KEY . ' value.');
     }
     return true;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:32,代码来源:Validator.php

示例12: testGetLinksTitleWithoutTitle

 public function testGetLinksTitleWithoutTitle()
 {
     $product = $this->getMockBuilder('\\Magento\\Catalog\\Model\\Product')->disableOriginalConstructor()->setMethods(['_wakeup', 'getLinksTitle'])->getMock();
     $product->expects($this->once())->method('getLinksTitle')->willReturn(null);
     $this->scopeConfig->expects($this->once())->method('getValue')->with(\Magento\Downloadable\Model\Link::XML_PATH_LINKS_TITLE, \Magento\Store\Model\ScopeInterface::SCOPE_STORE)->willReturn('scope_config_value');
     $this->assertEquals('scope_config_value', $this->helper->getLinksTitle($product));
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:7,代码来源:ConfigurationTest.php

示例13: validate

 /**
  * Validate process
  *
  * @param \Magento\Framework\DataObject $object
  * @return bool
  * @throws \Magento\Framework\Exception\LocalizedException
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function validate($object)
 {
     $attributeCode = $this->getAttribute()->getName();
     $postDataConfig = $object->getData('use_post_data_config') ?: [];
     $isUseConfig = in_array($attributeCode, $postDataConfig);
     if ($this->getAttribute()->getIsRequired()) {
         $attributeValue = $object->getData($attributeCode);
         if ($this->getAttribute()->isValueEmpty($attributeValue) && !$isUseConfig) {
             return false;
         }
     }
     if ($this->getAttribute()->getIsUnique()) {
         if (!$this->getAttribute()->getEntity()->checkAttributeUniqueValue($this->getAttribute(), $object)) {
             $label = $this->getAttribute()->getFrontend()->getLabel();
             throw new \Magento\Framework\Exception\LocalizedException(__('The value of attribute "%1" must be unique.', $label));
         }
     }
     if ($attributeCode == 'default_sort_by') {
         $available = $object->getData('available_sort_by') ?: [];
         $available = is_array($available) ? $available : explode(',', $available);
         $data = !in_array('default_sort_by', $postDataConfig) ? $object->getData($attributeCode) : $this->_scopeConfig->getValue("catalog/frontend/default_sort_by", \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
         if (!in_array($data, $available) && !in_array('available_sort_by', $postDataConfig)) {
             throw new \Magento\Framework\Exception\LocalizedException(__('Default Product Listing Sort by does not exist in Available Product Listing Sort By.'));
         }
     }
     return true;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:36,代码来源:Sortby.php

示例14: aroundRenderResult

 /**
  * @param \Magento\Framework\Controller\ResultInterface $subject
  * @param callable $proceed
  * @param ResponseHttp $response
  * @return \Magento\Framework\Controller\ResultInterface
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function aroundRenderResult(\Magento\Framework\Controller\ResultInterface $subject, \Closure $proceed, ResponseHttp $response)
 {
     $result = $proceed($response);
     $usePlugin = $this->registry->registry('use_page_cache_plugin');
     if (!$usePlugin || !$this->config->isEnabled() || $this->config->getType() != \Magento\PageCache\Model\Config::BUILT_IN) {
         return $result;
     }
     if ($this->state->getMode() == \Magento\Framework\App\State::MODE_DEVELOPER) {
         $cacheControlHeader = $response->getHeader('Cache-Control');
         if ($cacheControlHeader instanceof \Zend\Http\Header\HeaderInterface) {
             $response->setHeader('X-Magento-Cache-Control', $cacheControlHeader->getFieldValue());
         }
         $response->setHeader('X-Magento-Cache-Debug', 'MISS', true);
     }
     $tagsHeader = $response->getHeader('X-Magento-Tags');
     $tags = [];
     if ($tagsHeader) {
         $tags = explode(',', $tagsHeader->getFieldValue());
         $response->clearHeader('X-Magento-Tags');
     }
     $tags = array_unique(array_merge($tags, [\Magento\PageCache\Model\Cache\Type::CACHE_TAG]));
     $response->setHeader('X-Magento-Tags', implode(',', $tags));
     $this->kernel->process($response);
     return $result;
 }
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:32,代码来源:BuiltinPlugin.php

示例15: getValue

 /**
  * Retrieve information from payment configuration
  *
  * @param string $field
  * @param int|null $storeId
  *
  * @return mixed
  */
 public function getValue($field, $storeId = null)
 {
     if ($this->methodCode === null || $this->pathPattern === null) {
         return null;
     }
     return $this->scopeConfig->getValue(sprintf($this->pathPattern, $this->methodCode, $field), ScopeInterface::SCOPE_STORE, $storeId);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:15,代码来源:Config.php


注:本文中的Magento\Framework\App\Config\ScopeConfigInterface类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。