Skip to content

Commit 693a625

Browse files
committed
Second iteration use re-added readDirectory relative path
Use currentReaddir to make relative paths. Second iteration which uses way less code with the same result. - removed realpath usage - removed dirname usage - removed unused method - removed unused constant
1 parent d269ddd commit 693a625

File tree

1 file changed

+3
-18
lines changed
  • app/code/Magento/Developer/Model/XmlCatalog/Format

1 file changed

+3
-18
lines changed

app/code/Magento/Developer/Model/XmlCatalog/Format/PhpStorm.php

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
class PhpStorm implements FormatInterface
2020
{
2121
private const PROJECT_PATH_IDENTIFIER = '$PROJECT_DIR$';
22-
private const IDEA_PATH = '.idea';
2322

2423
/**
2524
* @var ReadInterface
@@ -63,8 +62,6 @@ public function generateCatalog(array $dictionary, $configFilePath)
6362
$componentNode = null;
6463
$projectNode = null;
6564

66-
$ideaDir = $this->resolveProjectPath($configFilePath);
67-
6865
try {
6966
$file = $this->fileWriteFactory->create(
7067
$configFilePath,
@@ -100,7 +97,7 @@ public function generateCatalog(array $dictionary, $configFilePath)
10097
foreach ($dictionary as $urn => $xsdPath) {
10198
$node = $dom->createElement('resource');
10299
$node->setAttribute('url', $urn);
103-
$node->setAttribute('location', $this->getFileLocationInProject($ideaDir, $xsdPath));
100+
$node->setAttribute('location', $this->getFileLocationInProject($xsdPath));
104101
$componentNode->appendChild($node);
105102
}
106103
$dom->formatOutput = true;
@@ -135,26 +132,14 @@ private function initEmptyFile(\DOMDocument $dom)
135132
return $projectNode;
136133
}
137134

138-
/**
139-
* Resolve PhpStorm Project Path
140-
*
141-
* @param string $configFilePath
142-
* @return string
143-
*/
144-
private function resolveProjectPath($configFilePath): string
145-
{
146-
return \str_replace('/' . self::IDEA_PATH, '', realpath(dirname($configFilePath)));
147-
}
148-
149135
/**
150136
* Resolve xsdpath to xml project path
151137
*
152-
* @param string $ideaDir
153138
* @param string $xsdPath
154139
* @return string
155140
*/
156-
private function getFileLocationInProject(string $ideaDir, string $xsdPath): string
141+
private function getFileLocationInProject(string $xsdPath): string
157142
{
158-
return \str_replace($ideaDir, self::PROJECT_PATH_IDENTIFIER, $xsdPath);
143+
return self::PROJECT_PATH_IDENTIFIER . DIRECTORY_SEPARATOR . $this->currentDirRead->getRelativePath($xsdPath);
159144
}
160145
}

0 commit comments

Comments
 (0)