Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 13 additions & 15 deletions app/code/Magento/Developer/Console/Command/GeneratePatchCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@

namespace Magento\Developer\Console\Command;

use Magento\Framework\App\ObjectManager;
use Magento\Framework\Component\ComponentRegistrar;
use Magento\Framework\Console\Cli;
use Magento\Framework\Exception\FileSystemException;
use Magento\Framework\Filesystem\DirectoryList;
use Magento\Framework\Filesystem\Directory\ReadFactory;
use Magento\Framework\Filesystem\Directory\WriteFactory;
use Magento\Framework\Filesystem\DirectoryList;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
Expand Down Expand Up @@ -58,20 +57,20 @@ class GeneratePatchCommand extends Command
* GeneratePatchCommand constructor.
*
* @param ComponentRegistrar $componentRegistrar
* @param DirectoryList|null $directoryList
* @param ReadFactory|null $readFactory
* @param WriteFactory|null $writeFactory
* @param DirectoryList $directoryList
* @param ReadFactory $readFactory
* @param WriteFactory $writeFactory
*/
public function __construct(
ComponentRegistrar $componentRegistrar,
DirectoryList $directoryList = null,
ReadFactory $readFactory = null,
WriteFactory $writeFactory = null
DirectoryList $directoryList,
ReadFactory $readFactory,
WriteFactory $writeFactory
) {
$this->componentRegistrar = $componentRegistrar;
$this->directoryList = $directoryList ?: ObjectManager::getInstance()->get(DirectoryList::class);
$this->readFactory = $readFactory ?: ObjectManager::getInstance()->get(ReadFactory::class);
$this->writeFactory = $writeFactory ?: ObjectManager::getInstance()->get(WriteFactory::class);
$this->directoryList = $directoryList;
$this->readFactory = $readFactory;
$this->writeFactory = $writeFactory;

parent::__construct();
}
Expand Down Expand Up @@ -120,6 +119,7 @@ protected function configure()
*
* @param InputInterface $input
* @param OutputInterface $output
*
* @return int
* @throws FileSystemException
*/
Expand Down Expand Up @@ -194,8 +194,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
private function getPatchTemplate(): string
{
$read = $this->readFactory->create(__DIR__ . '/');
$content = $read->readFile('patch_template.php.dist');
return $content;
return $read->readFile('patch_template.php.dist');
}

/**
Expand All @@ -207,7 +206,6 @@ private function getPatchTemplate(): string
private function getRevertMethodTemplate(): string
{
$read = $this->readFactory->create(__DIR__ . '/');
$content = $read->readFile('template_revert_function.php.dist');
return $content;
return $read->readFile('template_revert_function.php.dist');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Developer\Model\Css\PreProcessor\FileGenerator;

use Magento\Developer\Model\Config\Source\WorkflowType;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\App\State;
use Magento\Framework\App\View\Asset\Publisher;
use Magento\Framework\Css\PreProcessor\File\Temporary;
Expand All @@ -31,34 +32,35 @@ class PublicationDecorator extends RelatedGenerator
private $scopeConfig;

/**
* @var bool
* @var State
*/
private $hasRelatedPublishing;
private $state;

/**
* @var State
* @var bool
*/
private $state;
private $hasRelatedPublishing;

/**
* Constructor
*
* @param Repository $assetRepository
* @param Temporary $temporaryFile
* @param Publisher $assetPublisher
* @param ScopeConfigInterface $scopeConfig
* @param State $state
* @param bool $hasRelatedPublishing
*/
public function __construct(
Repository $assetRepository,
Temporary $temporaryFile,
Publisher $assetPublisher,
ScopeConfigInterface $scopeConfig,
State $state,
$hasRelatedPublishing = false
) {
parent::__construct($assetRepository, $temporaryFile);
$this->assetPublisher = $assetPublisher;
$this->scopeConfig = $scopeConfig;
$this->state = $state;
$this->hasRelatedPublishing = $hasRelatedPublishing;
}

Expand All @@ -69,7 +71,7 @@ protected function generateRelatedFile($relatedFileId, LocalInterface $asset)
{
$relatedAsset = parent::generateRelatedFile($relatedFileId, $asset);
$isClientSideCompilation =
$this->getState()->getMode() !== State::MODE_PRODUCTION
$this->state->getMode() !== State::MODE_PRODUCTION
&& WorkflowType::CLIENT_SIDE_COMPILATION === $this->scopeConfig->getValue(WorkflowType::CONFIG_NAME_PATH);

if ($this->hasRelatedPublishing || $isClientSideCompilation) {
Expand All @@ -78,17 +80,4 @@ protected function generateRelatedFile($relatedFileId, LocalInterface $asset)

return $relatedAsset;
}

/**
* @return State
* @deprecated 100.2.0
*/
private function getState()
{
if (null === $this->state) {
$this->state = ObjectManager::getInstance()->get(State::class);
}

return $this->state;
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?php
/**
* Plugin for the template engine factory that makes a decision of whether to activate debugging hints or not
*
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
Expand All @@ -16,6 +14,9 @@
use Magento\Store\Model\StoreManagerInterface;
use Magento\Framework\App\Request\Http;

/**
* Plugin for the template engine factory that makes a decision of whether to activate debugging hints or not
*/
class DebugHints
{
/**
Expand All @@ -26,22 +27,27 @@ class DebugHints
/**
* @var ScopeConfigInterface
*/
protected $scopeConfig;
private $scopeConfig;

/**
* @var StoreManagerInterface
*/
protected $storeManager;
private $storeManager;

/**
* @var DevHelper
*/
protected $devHelper;
private $devHelper;

/**
* @var DebugHintsFactory
*/
protected $debugHintsFactory;
private $debugHintsFactory;

/**
* @var Http
*/
private $http;

/**
* XPath of configuration of the debug hints
Expand All @@ -52,7 +58,7 @@ class DebugHints
*
* @var string
*/
protected $debugHintsPath;
private $debugHintsPath;

/**
* XPath of configuration of the debug hints show with parameter
Expand All @@ -77,8 +83,8 @@ class DebugHints
* @param StoreManagerInterface $storeManager
* @param DevHelper $devHelper
* @param DebugHintsFactory $debugHintsFactory
* @param string $debugHintsPath
* @param Http $http
* @param string $debugHintsPath
* @param string $debugHintsWithParam
* @param string $debugHintsParameter
*/
Expand All @@ -87,19 +93,17 @@ public function __construct(
StoreManagerInterface $storeManager,
DevHelper $devHelper,
DebugHintsFactory $debugHintsFactory,
Http $http,
$debugHintsPath,
Http $http = null,
$debugHintsWithParam = null,
$debugHintsParameter = null
) {
$this->scopeConfig = $scopeConfig;
$this->storeManager = $storeManager;
$this->devHelper = $devHelper;
$this->debugHintsFactory = $debugHintsFactory;
$this->http = $http;
$this->debugHintsPath = $debugHintsPath;
$this->http = $http ?: \Magento\Framework\App\ObjectManager::getInstance()->get(
\Magento\Framework\App\Request\Http::class
);
$this->debugHintsWithParam = $debugHintsWithParam;
$this->debugHintsParameter = $debugHintsParameter;
}
Expand Down Expand Up @@ -152,6 +156,7 @@ public function afterCreate(
]);
}
}

return $invocationResult;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,32 +42,34 @@ class PreprocessorStrategy implements PreProcessorInterface
private $state;

/**
* Constructor
*
* @param AlternativeSourceInterface $alternativeSource
* @param FrontendCompilation $frontendCompilation
* @param ScopeConfigInterface $scopeConfig
* @param State|null $state
*/
public function __construct(
AlternativeSourceInterface $alternativeSource,
FrontendCompilation $frontendCompilation,
ScopeConfigInterface $scopeConfig
ScopeConfigInterface $scopeConfig,
?State $state = null
) {
$this->frontendCompilation = $frontendCompilation;
$this->alternativeSource = $alternativeSource;
$this->scopeConfig = $scopeConfig;
$this->state = $state ?? ObjectManager::getInstance()->get(State::class);
}

/**
* Transform content and/or content type for the specified pre-processing chain object
*
* @param PreProcessor\Chain $chain
*
* @return void
*/
public function process(PreProcessor\Chain $chain)
{
$isClientSideCompilation =
$this->getState()->getMode() !== State::MODE_PRODUCTION
$this->state->getMode() !== State::MODE_PRODUCTION
&& WorkflowType::CLIENT_SIDE_COMPILATION === $this->scopeConfig->getValue(WorkflowType::CONFIG_NAME_PATH);

if ($isClientSideCompilation) {
Expand All @@ -76,16 +78,4 @@ public function process(PreProcessor\Chain $chain)
$this->alternativeSource->process($chain);
}
}

/**
* @return State
* @deprecated 100.2.0
*/
private function getState()
{
if (null === $this->state) {
$this->state = ObjectManager::getInstance()->get(State::class);
}
return $this->state;
}
}
12 changes: 7 additions & 5 deletions app/code/Magento/Developer/Model/XmlCatalog/Format/PhpStorm.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Developer\Model\XmlCatalog\Format;

use Magento\Framework\App\ObjectManager;
use Magento\Framework\DomDocument\DomDocumentFactory;
use Magento\Framework\Exception\FileSystemException;
use Magento\Framework\Filesystem\Directory\ReadFactory;
use Magento\Framework\Filesystem\Directory\ReadInterface;
use Magento\Framework\Filesystem\DriverPool;
use Magento\Framework\Filesystem\File\WriteFactory;

/**
Expand Down Expand Up @@ -43,18 +44,19 @@ class PhpStorm implements FormatInterface
public function __construct(
ReadFactory $readFactory,
WriteFactory $fileWriteFactory,
DomDocumentFactory $domDocumentFactory = null
DomDocumentFactory $domDocumentFactory
) {
$this->currentDirRead = $readFactory->create(getcwd());
$this->fileWriteFactory = $fileWriteFactory;
$this->domDocumentFactory = $domDocumentFactory ?: ObjectManager::getInstance()->get(DomDocumentFactory::class);
$this->domDocumentFactory = $domDocumentFactory;
}

/**
* Generate Catalog of URNs for the PhpStorm 9
*
* @param string[] $dictionary
* @param string $configFilePath relative path to the PhpStorm misc.xml
*
* @return void
*/
public function generateCatalog(array $dictionary, $configFilePath)
Expand All @@ -65,7 +67,7 @@ public function generateCatalog(array $dictionary, $configFilePath)
try {
$file = $this->fileWriteFactory->create(
$configFilePath,
\Magento\Framework\Filesystem\DriverPool::FILE,
DriverPool::FILE,
'r'
);
$dom = $this->domDocumentFactory->create();
Expand Down Expand Up @@ -103,7 +105,7 @@ public function generateCatalog(array $dictionary, $configFilePath)
$dom->formatOutput = true;
$file = $this->fileWriteFactory->create(
$configFilePath,
\Magento\Framework\Filesystem\DriverPool::FILE,
DriverPool::FILE,
'w'
);
$file->write($dom->saveXML());
Expand Down
Loading