Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
PreProcessor.php
Go to the documentation of this file.
1 <?php
8 
18 
23 {
29  protected $config;
30 
36  protected $dataProvider;
37 
41  protected $areaList;
42 
46  protected $translate;
47 
51  private $viewDesign;
52 
60  public function __construct(
65  DesignInterface $viewDesign = null
66  ) {
67  $this->config = $config;
68  $this->dataProvider = $dataProvider;
69  $this->areaList = $areaList;
70  $this->translate = $translate;
71  $this->viewDesign = $viewDesign ?? ObjectManager::getInstance()->get(DesignInterface::class);
72  }
73 
80  public function process(Chain $chain)
81  {
82  if ($this->isDictionaryPath($chain->getTargetAssetPath())) {
83  $context = $chain->getAsset()->getContext();
84 
85  $themePath = '*/*';
87 
88  if ($context instanceof FallbackContext) {
89  $themePath = $context->getThemePath();
90  $areaCode = $context->getAreaCode();
91 
92  $this->viewDesign->setDesignTheme($themePath, $areaCode);
93  }
94 
95  $area = $this->areaList->getArea($areaCode);
96  $area->load(\Magento\Framework\App\Area::PART_TRANSLATE);
97 
98  $this->translate->setLocale($context->getLocale())->loadData($areaCode, true);
99 
100  $chain->setContent(json_encode($this->dataProvider->getData($themePath)));
101  $chain->setContentType('json');
102  }
103  }
104 
111  protected function isDictionaryPath($path)
112  {
113  return (strpos($path, $this->config->getDictionaryFileName()) !== false);
114  }
115 }
__construct(Config $config, DataProviderInterface $dataProvider, AreaList $areaList, TranslateInterface $translate, DesignInterface $viewDesign=null)
jquery extjs ext tree mage adminhtml mage translate
Definition: tree.phtml:41