-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #182 from magento-mpi/develop
[MPI] - bug fix
- Loading branch information
Showing
9 changed files
with
361 additions
and
192 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
app/code/Magento/Developer/Model/Less/FileGenerator/PublicationDecorator.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Developer\Model\Less\FileGenerator; | ||
|
||
use Magento\Framework\Less\FileGenerator\RelatedGenerator; | ||
use Magento\Framework\View\Asset\LocalInterface; | ||
|
||
/** | ||
* Class PublicationDecorator | ||
* Decorates generator of related assets and publishes them | ||
* | ||
* @package Magento\Developer\Model\Less\FileGenerator | ||
*/ | ||
class PublicationDecorator extends RelatedGenerator | ||
{ | ||
/** | ||
* @var \Magento\Framework\App\View\Asset\Publisher | ||
*/ | ||
private $publisher; | ||
|
||
/** | ||
* @param \Magento\Framework\Filesystem $filesystem | ||
* @param \Magento\Framework\View\Asset\Repository $assetRepo | ||
* @param \Magento\Framework\Less\File\Temporary $temporaryFile | ||
* @param \Magento\Framework\App\View\Asset\Publisher $publisher | ||
*/ | ||
public function __construct( | ||
\Magento\Framework\Filesystem $filesystem, | ||
\Magento\Framework\View\Asset\Repository $assetRepo, | ||
\Magento\Framework\Less\File\Temporary $temporaryFile, | ||
\Magento\Framework\App\View\Asset\Publisher $publisher | ||
) { | ||
parent::__construct($filesystem, $assetRepo, $temporaryFile); | ||
$this->publisher = $publisher; | ||
} | ||
|
||
/** | ||
* {inheritdoc} | ||
*/ | ||
protected function generateRelatedFile($relatedFileId, LocalInterface $asset) | ||
{ | ||
$relatedAsset = parent::generateRelatedFile($relatedFileId, $asset); | ||
$this->publisher->publish($relatedAsset); | ||
return $relatedAsset; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Framework\Less; | ||
|
||
use Magento\Framework\App\Filesystem\DirectoryList; | ||
|
||
class Config | ||
{ | ||
/** | ||
* Temporary directory prefix | ||
*/ | ||
const TMP_LESS_DIR = 'less'; | ||
|
||
/** | ||
* Returns relative path to less materialization directory | ||
* | ||
* @return string | ||
*/ | ||
public function getLessMaterializationRelativePath() | ||
{ | ||
return DirectoryList::TMP_MATERIALIZATION_DIR . '/' . self::TMP_LESS_DIR; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Framework\Less\File; | ||
|
||
use Magento\Framework\App\Filesystem\DirectoryList; | ||
use Magento\Framework\Filesystem; | ||
use Magento\Framework\Less\Config; | ||
|
||
class Temporary | ||
{ | ||
/** | ||
* @var Config | ||
*/ | ||
private $config; | ||
|
||
/** | ||
* @var Filesystem\Directory\WriteInterface | ||
*/ | ||
private $tmpDirectory; | ||
|
||
/** | ||
* @param Filesystem $filesystem | ||
* @param Config $config | ||
*/ | ||
public function __construct( | ||
Filesystem $filesystem, | ||
Config $config | ||
) { | ||
$this->tmpDirectory = $filesystem->getDirectoryWrite(DirectoryList::VAR_DIR); | ||
$this->config = $config; | ||
} | ||
|
||
/** | ||
* Write down contents to a temporary file and return its absolute path | ||
* | ||
* @param string $relativePath | ||
* @param string $contents | ||
* @return string | ||
*/ | ||
public function createFile($relativePath, $contents) | ||
{ | ||
$filePath = $this->config->getLessMaterializationRelativePath() . '/' . $relativePath; | ||
|
||
if (!$this->tmpDirectory->isExist($filePath)) { | ||
$this->tmpDirectory->writeFile($filePath, $contents); | ||
} | ||
return $this->tmpDirectory->getAbsolutePath($filePath); | ||
} | ||
} |
Oops, something went wrong.