getParameter('linked_files', []); $linkedFolders = $this->getParameter(self::LINKED_FOLDERS, []); $linkingStrategy = $this->getParameter(self::LINKED_STRATEGY, self::ABSOLUTE_LINKING); $linkedEntities = array_merge($linkedFiles,$linkedFolders); if (sizeof($linkedFiles) == 0 && sizeof($linkedFolders) == 0) { throw new SkipException('No files and folders configured for sym-linking.'); } $sharedFolderName = $this->getParameter('shared', 'shared'); $sharedFolderPath = rtrim($this->getConfig()->deployment('to'), '/') . '/' . $sharedFolderName; $releasesDirectory = $this->getConfig()->release('directory', 'releases'); $releasesDirectoryPath = rtrim($this->getConfig()->deployment('to'), '/') . '/' . $releasesDirectory; $currentCopy = $releasesDirectoryPath . '/' . $this->getConfig()->getReleaseId(); $relativeDiffPath = str_replace($this->getConfig()->deployment('to'),'',$currentCopy) . '/'; foreach ($linkedEntities as $ePath) { if(is_array($ePath) && in_array($strategy = reset($ePath), $this->linkingStrategies ) ) { $entityPath = key($ePath); } else { $strategy = $linkingStrategy; $entityPath = $ePath; } $sharedEntityLinkedPath = "$sharedFolderPath/$entityPath"; if($strategy==self::RELATIVE_LINKING) { $parentFolderPath = dirname($entityPath); $relativePath = $parentFolderPath=='.'?$relativeDiffPath:$relativeDiffPath.$parentFolderPath.'/'; $sharedEntityLinkedPath = ltrim(preg_replace('/(\w+\/)/', '../', $relativePath),'/').$sharedFolderName .'/'. $entityPath; } $command = "ln -nfs $sharedEntityLinkedPath $currentCopy/$entityPath"; $this->runCommandRemote($command); } return true; } }