Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
BundleConfig.php
Go to the documentation of this file.
1 <?php
7 
10 
17 {
21  const VIEW_CONFIG_MODULE = 'Js_Bundle';
22 
26  const VIEW_CONFIG_BUNDLE_SIZE_NAME = 'bundle_size';
27 
33  private $viewConfig;
34 
42  private $themeProvider;
43 
49  private $config = [];
50 
57  public function __construct(
58  View\ConfigInterface $viewConfig,
59  ThemeProviderInterface $themeProvider
60  ) {
61  $this->viewConfig = $viewConfig;
62  $this->themeProvider = $themeProvider;
63  }
64 
72  public function getBundleFileMaxSize($area, $theme)
73  {
74  $size = $this->getConfig($area, $theme)->getVarValue(
75  self::VIEW_CONFIG_MODULE,
76  self::VIEW_CONFIG_BUNDLE_SIZE_NAME
77  );
78  $unit = preg_replace('/[^a-zA-Z]+/', '', $size);
79  $unit = strtoupper($unit);
80  switch ($unit) {
81  case 'KB':
82  return (int)$size;
83  case 'MB':
84  return (int)$size * 1024;
85  default:
86  return (int)($size / 1024);
87  }
88  }
89 
97  public function getExcludedDirectories($area, $theme)
98  {
99  return $this->getConfig($area, $theme)->getExcludedDir();
100  }
101 
109  public function getExcludedFiles($area, $theme)
110  {
111  return $this->getConfig($area, $theme)->getExcludedFiles();
112  }
113 
121  private function getConfig($area, $theme)
122  {
123  $themePath = $area . '/' . $theme;
124  if (!isset($this->config[$themePath])) {
125  $this->config[$themePath] = $this->viewConfig->getViewConfig([
126  'area' => $area,
127  'themeModel' => $this->themeProvider->getThemeByFullPath($themePath)
128  ]);
129  }
130  return $this->config[$themePath];
131  }
132 }
__construct(View\ConfigInterface $viewConfig, ThemeProviderInterface $themeProvider)
$theme