當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。