|
5 | 5 | */
|
6 | 6 | namespace Magento\Framework\View\Asset;
|
7 | 7 |
|
| 8 | +use Magento\Framework\App\ObjectManager; |
| 9 | + |
8 | 10 | /**
|
9 | 11 | * \Iterator that aggregates one or more assets and provides a single public file with equivalent behavior
|
10 | 12 | */
|
@@ -56,21 +58,23 @@ class Merged implements \Iterator
|
56 | 58 | * @param \Psr\Log\LoggerInterface $logger
|
57 | 59 | * @param MergeStrategyInterface $mergeStrategy
|
58 | 60 | * @param \Magento\Framework\View\Asset\Repository $assetRepo
|
59 |
| - * @param \Magento\Framework\App\View\Deployment\Version\StorageInterface $versionStorage |
60 | 61 | * @param MergeableInterface[] $assets
|
| 62 | + * @param \Magento\Framework\App\View\Deployment\Version\StorageInterface $versionStorage |
61 | 63 | * @throws \InvalidArgumentException
|
62 | 64 | */
|
63 | 65 | public function __construct(
|
64 | 66 | \Psr\Log\LoggerInterface $logger,
|
65 | 67 | MergeStrategyInterface $mergeStrategy,
|
66 | 68 | \Magento\Framework\View\Asset\Repository $assetRepo,
|
67 |
| - \Magento\Framework\App\View\Deployment\Version\StorageInterface $versionStorage, |
68 |
| - array $assets |
| 69 | + array $assets, |
| 70 | + \Magento\Framework\App\View\Deployment\Version\StorageInterface $versionStorage = null |
69 | 71 | ) {
|
70 | 72 | $this->logger = $logger;
|
71 | 73 | $this->mergeStrategy = $mergeStrategy;
|
72 | 74 | $this->assetRepo = $assetRepo;
|
73 |
| - $this->versionStorage = $versionStorage; |
| 75 | + $this->versionStorage = $versionStorage ?: ObjectManager::getInstance()->get( |
| 76 | + \Magento\Framework\App\View\Deployment\Version\StorageInterface::class |
| 77 | + ); |
74 | 78 |
|
75 | 79 | if (!$assets) {
|
76 | 80 | throw new \InvalidArgumentException('At least one asset has to be passed for merging.');
|
@@ -127,9 +131,9 @@ private function createMergedAsset(array $assets)
|
127 | 131 | }
|
128 | 132 | $paths = array_unique($paths);
|
129 | 133 |
|
130 |
| - $version=$this->versionStorage->load(); |
| 134 | + $version = $this->versionStorage->load(); |
131 | 135 | if ($version) {
|
132 |
| - $paths[]=$version; |
| 136 | + $paths[] = $version; |
133 | 137 | }
|
134 | 138 |
|
135 | 139 | $filePath = md5(implode('|', $paths)) . '.' . $this->contentType;
|
|
0 commit comments