Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Config.php
Go to the documentation of this file.
1 <?php
8 
11 
19 {
23  private $fileManager;
24 
28  protected $pageConfig;
29 
33  private $inline;
34 
42  public function __construct(
43  \Magento\Framework\View\Element\Context $context,
44  \Magento\Framework\View\Page\Config $pageConfig,
45  \Magento\Translation\Model\FileManager $fileManager,
46  Inline $inline,
47  array $data = []
48  ) {
49  parent::__construct($context, $data);
50  $this->pageConfig = $pageConfig;
51  $this->fileManager = $fileManager;
52  $this->inline = $inline;
53  }
54 
60  protected function _prepareLayout()
61  {
62  $this->addInlineTranslationConfig();
63 
64  return parent::_prepareLayout();
65  }
66 
71  private function addInlineTranslationConfig()
72  {
73  if ($this->inline->isAllowed()) {
74  $after = RequireJsConfig::REQUIRE_JS_FILE_NAME;
75  $tConfig = $this->fileManager->createTranslateConfigAsset();
76  $assetCollection = $this->pageConfig->getAssetCollection();
77  $assetCollection->insert(
78  $tConfig->getFilePath(),
79  $tConfig,
80  $after
81  );
82  }
83  }
84 }
__construct(\Magento\Framework\View\Element\Context $context, \Magento\Framework\View\Page\Config $pageConfig, \Magento\Translation\Model\FileManager $fileManager, Inline $inline, array $data=[])
Definition: Config.php:42