Skip to content

Optimized dev:urn-catalog:generate for PHPStorm #23291

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jul 18, 2019
Merged
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
15 changes: 14 additions & 1 deletion app/code/Magento/Developer/Model/XmlCatalog/Format/PhpStorm.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*/
class PhpStorm implements FormatInterface
{
private const PROJECT_PATH_IDENTIFIER = '$PROJECT_DIR$';

/**
* @var ReadInterface
*/
Expand Down Expand Up @@ -95,7 +97,7 @@ public function generateCatalog(array $dictionary, $configFilePath)
foreach ($dictionary as $urn => $xsdPath) {
$node = $dom->createElement('resource');
$node->setAttribute('url', $urn);
$node->setAttribute('location', $xsdPath);
$node->setAttribute('location', $this->getFileLocationInProject($xsdPath));
$componentNode->appendChild($node);
}
$dom->formatOutput = true;
Expand Down Expand Up @@ -129,4 +131,15 @@ private function initEmptyFile(\DOMDocument $dom)
$projectNode->appendChild($rootComponentNode);
return $projectNode;
}

/**
* Resolve xsdpath to xml project path
*
* @param string $xsdPath
* @return string
*/
private function getFileLocationInProject(string $xsdPath): string
{
return self::PROJECT_PATH_IDENTIFIER . DIRECTORY_SEPARATOR . $this->currentDirRead->getRelativePath($xsdPath);
}
}