45 private $pubStaticDir;
53 private $bundleFactory;
60 private $utilityFiles;
67 private $excludedCache = [];
94 $this->bundleFactory = $bundleFactory;
95 $this->bundleConfig = $bundleConfig;
96 $this->utilityFiles =
$files;
109 $bundle = $this->bundleFactory->create([
119 if ($this->pubStaticDir->isFile($mapFilePath)) {
121 $resultMap = $this->pubStaticDir->readFile($mapFilePath);
123 $files = json_decode($resultMap,
true);
126 $packageDir = $this->pubStaticDir->getAbsolutePath($area .
'/' .
$theme .
'/' . $locale);
127 $files = $this->utilityFiles->getFiles([$packageDir],
'*.*');
130 foreach (
$files as $filePath => $sourcePath) {
131 if (is_array($sourcePath)) {
133 $sourcePath = $sourcePath[
'area']
134 .
'/' . $sourcePath[
'theme']
135 .
'/' . $sourcePath[
'locale']
138 $sourcePath = str_replace(
'\\',
'/', $sourcePath);
139 $sourcePath = $this->pubStaticDir->getRelativePath($sourcePath);
140 $filePath = substr($sourcePath, strlen($area .
'/' .
$theme .
'/' . $locale) + 1);
143 $contentType = pathinfo($filePath, PATHINFO_EXTENSION);
144 if (!in_array($contentType, self::$availableTypes)) {
148 if ($this->hasMinVersion($filePath) || $this->isExcluded($filePath, $area,
$theme)) {
152 $bundle->addFile($filePath, $sourcePath, $contentType);
163 private function hasMinVersion($filePath)
165 if (in_array($filePath, $this->excludedCache)) {
169 $info = pathinfo($filePath);
170 if (strpos($filePath,
'.min.') !==
false) {
171 $this->excludedCache[] = str_replace(
".min.{$info['extension']}",
".{$info['extension']}", $filePath);
173 $pathToMinVersion =
$info[
'dirname'] .
'/' .
$info[
'filename'] .
'.min.' .
$info[
'extension'];
174 if ($this->pubStaticDir->isExist($pathToMinVersion)) {
175 $this->excludedCache[] = $filePath;
191 private function isExcluded($filePath, $area,
$theme)
193 $excludedFiles = $this->bundleConfig->getExcludedFiles($area,
$theme);
194 foreach ($excludedFiles as $excludedFileId) {
195 $excludedFilePath = $this->prepareExcludePath($excludedFileId);
196 if ($excludedFilePath === $filePath) {
201 $excludedDirs = $this->bundleConfig->getExcludedDirectories($area,
$theme);
202 foreach ($excludedDirs as $directoryId) {
203 $directoryPath = $this->prepareExcludePath($directoryId);
204 if (strpos($filePath, $directoryPath) === 0) {
217 private function prepareExcludePath(
$path)
221 if ($excludedModule ==
'Lib') {
222 return $excludedPath;
224 return $excludedModule .
'/' . $excludedPath;
__construct(Filesystem $filesystem, BundleInterfaceFactory $bundleFactory, BundleConfig $bundleConfig, Files $files)
deploy($area, $theme, $locale)
foreach( $_productCollection as $_product)() ?>" class $info
foreach($appDirs as $dir) $files