88 $parts = &$this->assets[$this->getContextCode($asset)][$asset->
getContentType()];
89 if (!isset($parts[$partIndex])) {
90 $parts[$partIndex][
'assets'] = [];
92 $parts[$partIndex][
'assets'][$this->
getAssetKey($asset)] = $asset;
101 $contextCode = $this->getContextCode($asset);
104 if (!isset($this->assets[$contextCode][
$type])) {
105 $this->assets[$contextCode][
$type] = [];
117 return $context->getAreaCode() .
':' . $context->getThemePath() .
':' . $context->getLocale();
126 $parts = $this->assets[$this->getContextCode($asset)][$asset->
getContentType()];
129 $minSpace = $maxPartSize;
131 if ($maxPartSize && count($parts)) {
132 foreach ($parts as $partIndex => $part) {
134 if ($space >= 0 && $space < $minSpace) {
136 $minIndex = $partIndex;
141 return ($maxPartSize != 0) ? ($minIndex >= 0) ? $minIndex : count($parts) : 0;
150 return $this->bundleConfig->getPartSize($asset->
getContext());
188 foreach (
$assets as $key => $asset) {
192 $partType = reset(
$assets)->getContentType();
196 " '" . $this->bundleNames[$partType] .
"':" .
$content .
"\n" .
211 $assetContextCode = $this->getContextCode($asset);
214 if (!isset($this->assetsContent[$assetContextCode][$assetContentType][$assetKey])) {
216 if (mb_detect_encoding(
$content) !==
"UTF-8") {
219 $this->assetsContent[$assetContextCode][$assetContentType][$assetKey] =
$content;
222 return $this->assetsContent[$assetContextCode][$assetContentType][$assetKey];
230 return "require.config({\n" .
232 " 'mage/requirejs/static': [\n" .
236 " 'statistician'\n" .
250 foreach ($this->assets as $types) {
255 $this->assetsContent = [];
262 protected function save($types)
267 foreach ($types as $parts) {
269 $assetsParts = reset($parts);
270 $context = reset($assetsParts[
'assets'])->getContext();
276 $this->content[max(0, count($this->content) - 1)] .= $this->
getInitJs();
278 foreach ($this->content as $partIndex =>
$content) {
279 $dir->writeFile($this->minification->addMinifiedSign($bundlePath . $partIndex .
'.js'),
$content);
290 $index = count($this->content) > 0 ? count($this->content) - 1 : 0 ;
291 foreach ($parts as $part) {
292 if (!isset($this->content[
$index])) {
293 $this->content[
$index] =
'';
294 }
elseif ($this->bundleConfig->isSplit($context)) {
296 $this->content[
$index] =
'';
getAssetContent(LocalInterface $asset)
addAsset(LocalInterface $asset)
add(LocalInterface $asset)
elseif(isset( $params[ 'redirect_parent']))
getSizePartWithNewAsset(LocalInterface $asset, $assets=[])
getMaxPartSize(LocalInterface $asset)
fillContent($parts, $context)
init(LocalInterface $asset)
getAssetKey(LocalInterface $asset)
__construct(Filesystem $filesystem, Bundle\ConfigInterface $bundleConfig, Minification $minification)
getPartIndex(LocalInterface $asset)