89 $mode = self::MODE_DEFAULT
91 $this->_configScope = $configScope;
96 $this->_appMode =
$mode;
99 throw new \InvalidArgumentException(
"Unknown application mode: {$mode}");
121 $this->_isDownloader = $flag;
133 $this->checkAreaCode(
$code);
135 if (isset($this->_areaCode)) {
136 throw new \Magento\Framework\Exception\LocalizedException(
140 $this->_configScope->setCurrentScope(
$code);
141 $this->_areaCode =
$code;
152 if (!isset($this->_areaCode)) {
153 throw new \Magento\Framework\Exception\LocalizedException(
181 $this->checkAreaCode($areaCode);
184 $this->_areaCode = $areaCode;
185 $this->_isAreaCodeEmulated =
true;
188 }
catch (\Exception $e) {
189 $this->_areaCode = $currentArea;
190 $this->_isAreaCodeEmulated =
false;
193 $this->_areaCode = $currentArea;
194 $this->_isAreaCodeEmulated =
false;
205 private function checkAreaCode($areaCode)
207 $areaCodes = array_merge(
209 $this->getAreaListInstance()->getCodes()
212 if (!in_array($areaCode, $areaCodes)) {
213 throw new \Magento\Framework\Exception\LocalizedException(
214 new \
Magento\Framework\
Phrase(
'Area code "%1" does not exist', [$areaCode])
225 private function getAreaListInstance()
227 if ($this->areaList ===
null) {
231 return $this->areaList;
__construct(\Magento\Framework\Config\ScopeInterface $configScope, $mode=self::MODE_DEFAULT)
emulateAreaCode($areaCode, $callback, $params=[])
if($exist=($block->getProductCollection() && $block->getProductCollection() ->getSize())) $mode
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
setIsDownloader($flag=true)