Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
RepositoryMap.php
Go to the documentation of this file.
1 <?php
7 
11 
16 {
25  const MAP_NAME = 'map.json';
26 
34  const RESULT_MAP_NAME = 'result_map.json';
35 
43  const REQUIRE_JS_MAP_NAME = 'requirejs-map.js';
44 
48  private $design;
49 
53  private $filesystem;
54 
58  private $maps = [];
59 
65  public function __construct(DesignInterface $design, Filesystem $filesystem)
66  {
67  $this->design = $design;
68  $this->filesystem = $filesystem;
69  }
70 
76  public function getMap($fileId, array $params)
77  {
78  $area = $params['area'];
79  $locale = $params['locale'];
80  $themePath = isset($params['theme']) ? $params['theme'] : $this->design->getThemePath($params['themeModel']);
81 
82  $path = "$area/$themePath/$locale/" . self::MAP_NAME;
83  if (!isset($this->maps[$path])) {
84  $this->maps[$path] = [];
86  $staticDir = $this->filesystem->getDirectoryRead(DirectoryList::STATIC_VIEW);
87  if ($staticDir->isFile($path)) {
88  $map = $staticDir->readFile($path);
89  if ($map) {
90  $this->maps[$path] = json_decode($map, true);
91  }
92  }
93  }
94 
95  if (isset($this->maps[$path][$fileId])) {
96  return $this->maps[$path][$fileId];
97  }
98  return [];
99  }
100 }
__construct(DesignInterface $design, Filesystem $filesystem)
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
Definition: website.php:18
$filesystem