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


PHP State::getMode方法代码示例

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


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

示例1: process

 /**
  * @param string $sourceFilePath
  * @return string
  */
 public function process($sourceFilePath)
 {
     $options = ['relativeUrls' => false, 'compress' => $this->appState->getMode() !== State::MODE_DEVELOPER];
     try {
         $parser = new \Less_Parser($options);
         $parser->parseFile($sourceFilePath, '');
         return $parser->getCss();
     } catch (\Exception $e) {
         $messagePrefix = 'CSS compilation from LESS ';
         $this->logger->critical($messagePrefix . $e->getMessage());
         return $messagePrefix . $e->getMessage();
     }
 }
开发者ID:kid17,项目名称:magento2,代码行数:17,代码来源:Oyejorge.php

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

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

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

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

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

示例7: 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,代码来源:

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

示例9: _callObserverMethod

 /**
  * @param \Magento\Framework\Event\ObserverInterface $object
  * @param Observer $observer
  * @return $this
  * @throws \LogicException
  */
 protected function _callObserverMethod($object, $observer)
 {
     if ($object instanceof \Magento\Framework\Event\ObserverInterface) {
         $object->execute($observer);
     } elseif ($this->_appState->getMode() == \Magento\Framework\App\State::MODE_DEVELOPER) {
         throw new \LogicException(sprintf('Observer "%s" must implement interface "%s"', get_class($object), 'Magento\\Framework\\Event\\ObserverInterface'));
     }
     return $this;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:15,代码来源:InvokerDefault.php

示例10: _callObserverMethod

 /**
  * Performs non-existent observer method calls protection
  *
  * @param object $object
  * @param string $method
  * @param Observer $observer
  * @return $this
  * @throws \LogicException
  */
 protected function _callObserverMethod($object, $method, $observer)
 {
     if (method_exists($object, $method) && is_callable([$object, $method])) {
         $object->{$method}($observer);
     } elseif ($this->_appState->getMode() == \Magento\Framework\App\State::MODE_DEVELOPER) {
         throw new \LogicException('Method "' . $method . '" is not defined in "' . get_class($object) . '"');
     }
     return $this;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:18,代码来源:InvokerDefault.php

示例11: afterToHtml

 /**
  * Wrap template with the debugging hints in comments
  *
  * @param Template $subject
  * @param string $result
  *
  * @return string
  */
 public function afterToHtml(Template $subject, $result)
 {
     if ($this->scopeConfig->getValue(self::XML_PATH_DEBUG_TEMPLATE_HINTS, ScopeInterface::SCOPE_STORE) && $this->appState->getMode() === State::MODE_DEVELOPER) {
         $name = $subject->getNameInLayout();
         $template = $subject->getTemplateFile();
         $class = get_class($subject);
         $result = "<!-- BEGIN {$name} using {$template} \n" . $class . '-->' . $result . "<!-- END {$name} using {$template} -->";
     }
     return $result;
 }
开发者ID:aohorodnyk,项目名称:module-debug-comment,代码行数:18,代码来源:DebugHints.php

示例12: beforeDispatch

 /**
  * Add new theme from filesystem
  *
  * @param AbstractAction $subject
  * @param RequestInterface $request
  *
  * @return void
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function beforeDispatch(AbstractAction $subject, RequestInterface $request)
 {
     try {
         if ($this->appState->getMode() != AppState::MODE_PRODUCTION) {
             $this->themeRegistration->register();
         }
     } catch (LocalizedException $e) {
         $this->logger->critical($e);
     }
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:19,代码来源:Registration.php

示例13: aroundDispatch

 /**
  * @param \Magento\Framework\App\FrontControllerInterface $subject
  * @param callable $proceed
  * @param \Magento\Framework\App\RequestInterface $request
  * @return false|\Magento\Framework\App\Response\Http|\Magento\Framework\Controller\ResultInterface
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function aroundDispatch(\Magento\Framework\App\FrontControllerInterface $subject, \Closure $proceed, \Magento\Framework\App\RequestInterface $request)
 {
     $response = $proceed($request);
     if ($this->config->getType() == \Magento\PageCache\Model\Config::VARNISH && $this->config->isEnabled() && $response instanceof \Magento\Framework\App\Response\Http) {
         $this->version->process();
         if ($this->state->getMode() == \Magento\Framework\App\State::MODE_DEVELOPER) {
             $response->setHeader('X-Magento-Debug', 1);
         }
     }
     return $response;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:18,代码来源:VarnishPlugin.php

示例14: publish

 /**
  * {@inheritdoc}
  */
 public function publish(Asset\LocalInterface $asset)
 {
     if ($this->appState->getMode() === \Magento\Framework\App\State::MODE_DEVELOPER) {
         return false;
     }
     $dir = $this->filesystem->getDirectoryRead(\Magento\Framework\App\Filesystem::STATIC_VIEW_DIR);
     if ($dir->isExist($asset->getPath())) {
         return true;
     }
     return $this->publishAsset($asset);
 }
开发者ID:,项目名称:,代码行数:14,代码来源:

示例15: aroundRenderResult

 /**
  * @param \Magento\Framework\Controller\ResultInterface $subject
  * @param callable $proceed
  * @param ResponseHttp $response
  * @return \Magento\Framework\Controller\ResultInterface
  */
 public function aroundRenderResult(\Magento\Framework\Controller\ResultInterface $subject, \Closure $proceed, ResponseHttp $response)
 {
     $proceed($response);
     $usePlugin = $this->registry->registry('use_page_cache_plugin');
     if ($this->config->getType() == \Magento\PageCache\Model\Config::VARNISH && $this->config->isEnabled() && $usePlugin) {
         $this->version->process();
         if ($this->state->getMode() == \Magento\Framework\App\State::MODE_DEVELOPER) {
             $response->setHeader('X-Magento-Debug', 1);
         }
     }
     return $subject;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:18,代码来源:VarnishPlugin.php


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