Skip to content

Commit 0fbc4a2

Browse files
author
Olga Kopylova
committed
MAGETWO-38010: Warnings During Running Static View Files Deployment Command
- removed unused variables - refactored a method with NPath complexity
1 parent dbe14b2 commit 0fbc4a2

File tree

2 files changed

+30
-27
lines changed

2 files changed

+30
-27
lines changed

lib/internal/Magento/Framework/View/Asset/Source.php

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ public function getContent(LocalInterface $asset)
130130
private function preProcess(LocalInterface $asset)
131131
{
132132
$sourceFile = $this->findSourceFile($asset);
133-
$dirCode = DirectoryList::ROOT;
134133
if ($sourceFile !== false) {
135134
$path = $this->rootDir->getRelativePath($sourceFile);
136135
} else {
@@ -143,20 +142,10 @@ private function preProcess(LocalInterface $asset)
143142
return unserialize($cached);
144143
}
145144

146-
$origContent = $path ? $this->rootDir->readFile($path) : '';
147-
$origContentType = $this->getContentType($path) ?: $asset->getContentType();
148-
149-
$chain = $this->chainFactory->create(
150-
[
151-
'asset' => $asset,
152-
'origContent' => $origContent,
153-
'origContentType' => $origContentType,
154-
'origAssetPath' => $path
155-
]
156-
);
157-
145+
$chain = $this->createChain($asset, $path);
158146
$this->preProcessorPool->process($chain);
159147
$chain->assertValid();
148+
$dirCode = DirectoryList::ROOT;
160149
if ($chain->isChanged()) {
161150
$dirCode = DirectoryList::VAR_DIR;
162151
$path = DirectoryList::TMP_MATERIALIZATION_DIR . '/source/' . $chain->getTargetAssetPath();
@@ -257,4 +246,32 @@ public function findRelativeSourceFilePath(LocalInterface $asset)
257246
}
258247
return $this->rootDir->getRelativePath($sourceFile);
259248
}
249+
250+
/**
251+
* Creates a chain for pre-processing
252+
*
253+
* @param LocalInterface $asset
254+
* @param string|bool $path
255+
* @return PreProcessor\Chain
256+
*/
257+
private function createChain(LocalInterface $asset, $path)
258+
{
259+
if ($path) {
260+
$origContent = $this->rootDir->readFile($path);
261+
$origContentType = $this->getContentType($path);
262+
} else {
263+
$origContent = '';
264+
$origContentType = $asset->getContentType();
265+
}
266+
267+
$chain = $this->chainFactory->create(
268+
[
269+
'asset' => $asset,
270+
'origContent' => $origContent,
271+
'origContentType' => $origContentType,
272+
'origAssetPath' => $path
273+
]
274+
);
275+
return $chain;
276+
}
260277
}

setup/src/Magento/Setup/Model/Deployer.php

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@
2424
*/
2525
class Deployer
2626
{
27-
/**
28-
* @var Filesystem
29-
*/
30-
private $filesystem;
31-
3227
/** @var Files */
3328
private $filesUtil;
3429

@@ -41,9 +36,6 @@ class Deployer
4136
/** @var Version\StorageInterface */
4237
private $versionStorage;
4338

44-
/** @var \Magento\Framework\Stdlib\DateTime */
45-
private $dateTime;
46-
4739
/** @var \Magento\Framework\View\Asset\Repository */
4840
private $assetRepo;
4941

@@ -85,29 +77,23 @@ class Deployer
8577

8678
/**
8779
* @param Files $filesUtil
88-
* @param Filesystem $filesystem
8980
* @param OutputInterface $output
9081
* @param Version\StorageInterface $versionStorage
91-
* @param \Magento\Framework\Stdlib\DateTime $dateTime
9282
* @param \Magento\Framework\View\Asset\MinifyService $minifyService
9383
* @param JsTranslationConfig $jsTranslationConfig
9484
* @param bool $isDryRun
9585
*/
9686
public function __construct(
9787
Files $filesUtil,
98-
Filesystem $filesystem,
9988
OutputInterface $output,
10089
Version\StorageInterface $versionStorage,
101-
\Magento\Framework\Stdlib\DateTime $dateTime,
10290
\Magento\Framework\View\Asset\MinifyService $minifyService,
10391
JsTranslationConfig $jsTranslationConfig,
10492
$isDryRun = false
10593
) {
106-
$this->filesystem = $filesystem;
10794
$this->filesUtil = $filesUtil;
10895
$this->output = $output;
10996
$this->versionStorage = $versionStorage;
110-
$this->dateTime = $dateTime;
11197
$this->isDryRun = $isDryRun;
11298
$this->minifyService = $minifyService;
11399
$this->jsTranslationConfig = $jsTranslationConfig;

0 commit comments

Comments
 (0)