public function addPluginVcsMapping(Plugin $plugin, $shopwarePath)
{
$vcsMappingFile = $shopwarePath . '/.idea/vcs.xml';
$pluginDestPath = $plugin->module . "/" . $plugin->name;
if (!file_exists($vcsMappingFile)) {
return;
}
$mapping = file_get_contents($vcsMappingFile);
$xml = new \SimpleXMLElement($mapping);
foreach ($xml->component->mapping as $mapping) {
// if already mapped, return
if (strpos($this->normalize($mapping['directory']), $this->normalize($pluginDestPath)) !== false) {
return;
}
}
$mappingDirectory = '$PROJECT_DIR$/engine/Shopware/Plugins/Local/' . $pluginDestPath;
// mapping needs to be created
$newMapping = $xml->component->addChild('mapping');
$newMapping->addAttribute('vcs', 'Git');
$newMapping->addAttribute('directory', $mappingDirectory);
$xml->asXML($vcsMappingFile);
}