• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP App\State类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: read

 /**
  * Read configuration by code
  *
  * @param string $code
  * @return array
  */
 public function read($code = null)
 {
     if ($this->_appState->isInstalled()) {
         if (empty($code)) {
             $store = $this->_storeManager->getStore();
         } elseif ($code == \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT) {
             $store = $this->_storeManager->getDefaultStoreView();
         } else {
             $store = $this->_storeFactory->create();
             $store->load($code);
         }
         if (!$store->getCode()) {
             throw NoSuchEntityException::singleField('storeCode', $code);
         }
         $websiteConfig = $this->_scopePool->getScope(\Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE, $store->getWebsite()->getCode())->getSource();
         $config = array_replace_recursive($websiteConfig, $this->_initialConfig->getData("stores|{$code}"));
         $collection = $this->_collectionFactory->create(array('scope' => \Magento\Store\Model\ScopeInterface::SCOPE_STORES, 'scopeId' => $store->getId()));
         $dbStoreConfig = array();
         foreach ($collection as $item) {
             $dbStoreConfig[$item->getPath()] = $item->getValue();
         }
         $config = $this->_converter->convert($dbStoreConfig, $config);
     } else {
         $websiteConfig = $this->_scopePool->getScope(\Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE, \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT)->getSource();
         $config = $this->_converter->convert($websiteConfig, $this->_initialConfig->getData("stores|{$code}"));
     }
     return $config;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:34,代码来源:Store.php


示例2: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output->setDecorated(true);
     $this->appState->setAreaCode('catalog');
     $connection = $this->attributeResource->getConnection();
     $attributeTables = $this->getAttributeTables();
     $progress = new \Symfony\Component\Console\Helper\ProgressBar($output, count($attributeTables));
     $progress->setFormat('<comment>%message%</comment> %current%/%max% [%bar%] %percent:3s%% %elapsed%');
     $this->attributeResource->beginTransaction();
     try {
         // Find and remove unused attributes
         foreach ($attributeTables as $attributeTable) {
             $progress->setMessage($attributeTable . ' ');
             $affectedIds = $this->getAffectedAttributeIds($connection, $attributeTable);
             if (count($affectedIds) > 0) {
                 $connection->delete($attributeTable, ['value_id in (?)' => $affectedIds]);
             }
             $progress->advance();
         }
         $this->attributeResource->commit();
         $output->writeln("");
         $output->writeln("<info>Unused product attributes successfully cleaned up:</info>");
         $output->writeln("<comment>  " . implode("\n  ", $attributeTables) . "</comment>");
     } catch (\Exception $exception) {
         $this->attributeResource->rollBack();
         $output->writeln("");
         $output->writeln("<error>{$exception->getMessage()}</error>");
     }
 }
开发者ID:dragonsword007008,项目名称:magento2,代码行数:32,代码来源:ProductAttributesCleanUp.php


示例3: build

 /**
  * @param array $buildSubject
  * @return mixed
  */
 public function build(array $buildSubject)
 {
     /** @var \Magento\Payment\Gateway\Data\PaymentDataObject $paymentDataObject */
     $paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($buildSubject);
     $payment = $paymentDataObject->getPayment();
     $order = $paymentDataObject->getOrder();
     $storeId = $order->getStoreId();
     $request = [];
     if ($this->adyenHelper->getAdyenCcConfigDataFlag('cse_enabled', $storeId)) {
         $request['additionalData']['card.encrypted.json'] = $payment->getAdditionalInformation("encrypted_data");
     } else {
         $requestCreditCardDetails = ["expiryMonth" => $payment->getCcExpMonth(), "expiryYear" => $payment->getCcExpYear(), "holderName" => $payment->getCcOwner(), "number" => $payment->getCcNumber(), "cvc" => $payment->getCcCid()];
         $cardDetails['card'] = $requestCreditCardDetails;
         $request = array_merge($request, $cardDetails);
     }
     /**
      * if MOTO for backend is enabled use MOTO as shopper interaction type
      */
     $enableMoto = $this->adyenHelper->getAdyenCcConfigDataFlag('enable_moto', $storeId);
     if ($this->appState->getAreaCode() === \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE && $enableMoto) {
         $request['shopperInteraction'] = "Moto";
     }
     // if installments is set add it into the request
     if ($payment->getAdditionalInformation('number_of_installments') && $payment->getAdditionalInformation('number_of_installments') > 0) {
         $request['installments']['value'] = $payment->getAdditionalInformation('number_of_installments');
     }
     return $request;
 }
开发者ID:Adyen,项目名称:adyen-magento2,代码行数:32,代码来源:CcAuthorizationDataBuilder.php


示例4: get

 /**
  * Get config value by key
  *
  * @param null|string $path
  * @param null|mixed $default
  * @return null|mixed
  */
 public function get($path = null, $default = null)
 {
     if (!$this->_appState->isInstalled() && !in_array($this->_configScope->getCurrentScope(), array('global', 'install'))) {
         return $default;
     }
     return parent::get($path, $default);
 }
开发者ID:,项目名称:,代码行数:14,代码来源:


示例5: testProcess

 public function testProcess()
 {
     $sourceFilePath = realpath(__DIR__ . '/_files/oyejorge.less');
     $expectedCss = $this->state->getMode() === State::MODE_DEVELOPER ? file_get_contents(__DIR__ . '/_files/oyejorge_dev.css') : file_get_contents(__DIR__ . '/_files/oyejorge.css');
     $actualCss = $this->model->process($sourceFilePath);
     $this->assertEquals($this->cutCopyrights($expectedCss), $actualCss);
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:7,代码来源:OyejorgeTest.php


示例6: isEnabled

 /**
  * Check whether asset minification is on for specified content type
  *
  * @param string $contentType
  * @return bool
  */
 public function isEnabled($contentType)
 {
     if (!isset($this->configCache[self::XML_PATH_MINIFICATION_ENABLED][$contentType])) {
         $this->configCache[self::XML_PATH_MINIFICATION_ENABLED][$contentType] = $this->appState->getMode() != State::MODE_DEVELOPER && (bool) $this->scopeConfig->isSetFlag(sprintf(self::XML_PATH_MINIFICATION_ENABLED, $contentType), $this->scope);
     }
     return $this->configCache[self::XML_PATH_MINIFICATION_ENABLED][$contentType];
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:13,代码来源:Minification.php


示例7: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->appState->setAreaCode('catalog');
     /** @var ProductCollection $productCollection */
     $productCollection = $this->productCollectionFactory->create();
     $productIds = $productCollection->getAllIds();
     if (!count($productIds)) {
         $output->writeln("<info>No product images to resize</info>");
         return;
     }
     try {
         foreach ($productIds as $productId) {
             try {
                 /** @var Product $product */
                 $product = $this->productRepository->getById($productId);
             } catch (NoSuchEntityException $e) {
                 continue;
             }
             /** @var ImageCache $imageCache */
             $imageCache = $this->imageCacheFactory->create();
             $imageCache->generate($product);
             $output->write(".");
         }
     } catch (\Exception $e) {
         $output->writeln("<error>{$e->getMessage()}</error>");
         return;
     }
     $output->write("\n");
     $output->writeln("<info>Product images resized successfully</info>");
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:33,代码来源:ImagesResizeCommand.php


示例8: testNotUnlockProcessInProductionMode

 public function testNotUnlockProcessInProductionMode()
 {
     $this->stateMock->expects(self::exactly(2))->method('getMode')->willReturn(State::MODE_PRODUCTION);
     $this->filesystemMock->expects(self::never())->method('getDirectoryWrite');
     $this->lockerProcess->lockProcess(self::LOCK_NAME);
     $this->lockerProcess->unlockProcess();
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:7,代码来源:LockerProcessTest.php


示例9: process

 /**
  * @param string $sourceFilePath
  * @return string
  */
 public function process($sourceFilePath)
 {
     $options = ['relativeUrls' => false, 'compress' => $this->appState->getMode() !== State::MODE_DEVELOPER];
     $parser = new \Less_Parser($options);
     $parser->parseFile($sourceFilePath, '');
     return $parser->getCss();
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:11,代码来源:Oyejorge.php


示例10: getValue

 /**
  * Retrieve deployment version of static files
  *
  * @return string
  */
 public function getValue()
 {
     if (!$this->cachedValue) {
         $this->cachedValue = $this->readValue($this->appState->getMode());
     }
     return $this->cachedValue;
 }
开发者ID:,项目名称:,代码行数:12,代码来源:


示例11: beforeLaunch

 /**
  * Perform required checks before cron run
  *
  * @param \Magento\Framework\App\Cron $subject
  *
  * @return void
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  * @throws \Magento\Framework\Exception
  */
 public function beforeLaunch(\Magento\Framework\App\Cron $subject)
 {
     $this->_sidResolver->setUseSessionInUrl(false);
     if (false == $this->_appState->isInstalled()) {
         throw new \Magento\Framework\Exception('Application is not installed yet, please complete the installation first.');
     }
 }
开发者ID:aiesh,项目名称:magento2,代码行数:16,代码来源:ApplicationInitializer.php


示例12: testWidgetDirective

 /**
  * @return void
  */
 public function testWidgetDirective()
 {
     $result = 'some text';
     $construction = ['{{widget type="Widget\\Link" anchor_text="Test" template="block.phtml" id_path="p/1"}}', 'widget', ' type="" anchor_text="Test" template="block.phtml" id_path="p/1"'];
     $this->appStateMock->expects($this->once())->method('emulateAreaCode')->with('frontend', [$this->filterEmulate, 'generateWidget'], [$construction])->willReturn($result);
     $this->assertSame($result, $this->filterEmulate->widgetDirective($construction));
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:10,代码来源:FilterEmulateTest.php


示例13: processContent

 /**
  * @inheritdoc
  * @throws ContentProcessorException
  */
 public function processContent(File $asset)
 {
     $path = $asset->getPath();
     try {
         $parser = new \Less_Parser(['relativeUrls' => false, 'compress' => $this->appState->getMode() !== State::MODE_DEVELOPER]);
         $content = $this->assetSource->getContent($asset);
         if (trim($content) === '') {
             return '';
         }
         $tmpFilePath = $this->temporaryFile->createFile($path, $content);
         gc_disable();
         $parser->parseFile($tmpFilePath, '');
         $content = $parser->getCss();
         gc_enable();
         if (trim($content) === '') {
             $errorMessage = PHP_EOL . self::ERROR_MESSAGE_PREFIX . PHP_EOL . $path;
             $this->logger->critical($errorMessage);
             throw new ContentProcessorException(new Phrase($errorMessage));
         }
         return $content;
     } catch (\Exception $e) {
         $errorMessage = PHP_EOL . self::ERROR_MESSAGE_PREFIX . PHP_EOL . $path . PHP_EOL . $e->getMessage();
         $this->logger->critical($errorMessage);
         throw new ContentProcessorException(new Phrase($errorMessage));
     }
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:30,代码来源:Processor.php


示例14: ensureSourceFile

 /**
  * Make sure the aggregated configuration is materialized
  *
  * By default write the file if it doesn't exist, but in developer mode always do it.
  *
  * @param string $relPath
  * @return void
  */
 private function ensureSourceFile($relPath)
 {
     $dir = $this->filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem::STATIC_VIEW_DIR);
     if ($this->appState->getMode() == \Magento\Framework\App\State::MODE_DEVELOPER || !$dir->isExist($relPath)) {
         $dir->writeFile($relPath, $this->config->getConfig());
     }
 }
开发者ID:aiesh,项目名称:magento2,代码行数:15,代码来源:FileManager.php


示例15: load

 /**
  * Load design
  *
  * @return void
  */
 public function load()
 {
     $area = $this->_areaList->getArea($this->appState->getAreaCode());
     $area->load(\Magento\Framework\App\Area::PART_DESIGN);
     $area->load(\Magento\Framework\App\Area::PART_TRANSLATE);
     $area->detectDesign($this->_request);
 }
开发者ID:,项目名称:,代码行数:12,代码来源:


示例16: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->appState->setAreaCode('catalog');
     /** @var ProductCollection $productCollection */
     $productCollection = $this->productCollectionFactory->create();
     $productIds = $productCollection->getAllIds();
     if (!count($productIds)) {
         $output->writeln("<info>No product images to resize</info>");
         // we must have an exit code higher than zero to indicate something was wrong
         return \Magento\Framework\Console\Cli::RETURN_SUCCESS;
     }
     try {
         foreach ($productIds as $productId) {
             try {
                 /** @var Product $product */
                 $product = $this->productRepository->getById($productId);
             } catch (NoSuchEntityException $e) {
                 continue;
             }
             /** @var ImageCache $imageCache */
             $imageCache = $this->imageCacheFactory->create();
             $imageCache->generate($product);
             $output->write(".");
         }
     } catch (\Exception $e) {
         $output->writeln("<error>{$e->getMessage()}</error>");
         // we must have an exit code higher than zero to indicate something was wrong
         return \Magento\Framework\Console\Cli::RETURN_FAILURE;
     }
     $output->write("\n");
     $output->writeln("<info>Product images resized successfully</info>");
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:35,代码来源:ImagesResizeCommand.php


示例17: 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


示例18: setUp

 protected function setUp()
 {
     $this->requestMock = $this->getMock('\\Magento\\Framework\\App\\Request\\Http', ['getBasePath', 'isSecure', 'getHttpHost'], [], '', false, false);
     $this->requestMock->expects($this->atLeastOnce())->method('getBasePath')->will($this->returnValue('/'));
     $this->requestMock->expects($this->atLeastOnce())->method('getHttpHost')->will($this->returnValue('init.host'));
     $this->appState = $this->getMock('\\Magento\\Framework\\App\\State', ['isInstalled'], [], '', false, false);
     $this->appState->expects($this->atLeastOnce())->method('isInstalled')->will($this->returnValue(true));
 }
开发者ID:,项目名称:,代码行数:8,代码来源:


示例19: testBeforeExecuteWithProductionMode

 public function testBeforeExecuteWithProductionMode()
 {
     $this->appState->expects($this->once())->method('getMode')->willReturn('production');
     $this->themeRegistration->expects($this->never())->method('register');
     $this->logger->expects($this->never())->method('critical');
     $object = new Registration($this->themeRegistration, $this->logger, $this->appState);
     $object->beforeExecute($this->abstractAction, $this->request);
 }
开发者ID:nblair,项目名称:magescotch,代码行数:8,代码来源:RegistrationTest.php


示例20: __construct

 /**
  * @param State\OptionsInterface $options
  * @param \Magento\Framework\App\Cache\Frontend\Pool $cacheFrontendPool
  * @param \Magento\Framework\App\State $appState
  * @param bool $banAll Whether all cache types are forced to be disabled
  */
 public function __construct(State\OptionsInterface $options, \Magento\Framework\App\Cache\Frontend\Pool $cacheFrontendPool, \Magento\Framework\App\State $appState, $banAll = false)
 {
     $this->_options = $options;
     $this->_cacheFrontend = $cacheFrontendPool->get(\Magento\Framework\App\Cache\Frontend\Pool::DEFAULT_FRONTEND_ID);
     if ($appState->isInstalled()) {
         $this->_loadTypeStatuses($banAll);
     }
 }
开发者ID:,项目名称:,代码行数:14,代码来源:



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP App\ViewInterface类代码示例发布时间:2022-05-23
下一篇:
PHP App\ScopeResolverInterface类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap