Browse Source

Get path and strategy.

1.0
Андрей Колченко 10 years ago
parent
commit
d52927fe07
  1. 30
      Mage/Task/BuiltIn/Filesystem/LinkSharedFilesTask.php

30
Mage/Task/BuiltIn/Filesystem/LinkSharedFilesTask.php

@ -35,7 +35,7 @@ class LinkSharedFilesTask extends AbstractTask implements IsReleaseAware
/** /**
* @var array * @var array
*/ */
public $linkingStrategies = array( private static $linkingStrategies = array(
self::ABSOLUTE_LINKING, self::ABSOLUTE_LINKING,
self::RELATIVE_LINKING self::RELATIVE_LINKING
); );
@ -77,12 +77,7 @@ class LinkSharedFilesTask extends AbstractTask implements IsReleaseAware
$relativeDiffPath = str_replace($this->getConfig()->deployment('to'), '', $currentCopy) . '/'; $relativeDiffPath = str_replace($this->getConfig()->deployment('to'), '', $currentCopy) . '/';
foreach ($linkedEntities as $ePath) { foreach ($linkedEntities as $ePath) {
if (is_array($ePath) && in_array($strategy = reset($ePath), $this->linkingStrategies)) { list($entityPath, $strategy) = $this->getPath($ePath);
$entityPath = key($ePath);
} else {
$strategy = $linkingStrategy;
$entityPath = $ePath;
}
$sharedEntityLinkedPath = "$sharedFolderPath/$entityPath"; $sharedEntityLinkedPath = "$sharedFolderPath/$entityPath";
if ($strategy == self::RELATIVE_LINKING) { if ($strategy == self::RELATIVE_LINKING) {
$parentFolderPath = dirname($entityPath); $parentFolderPath = dirname($entityPath);
@ -98,4 +93,25 @@ class LinkSharedFilesTask extends AbstractTask implements IsReleaseAware
return true; return true;
} }
/**
* @param array|string $linkedEntity
*
* @return array [$path, $strategy]
*/
private function getPath($linkedEntity)
{
$linkingStrategy = $this->getParameter(self::LINKED_STRATEGY, self::ABSOLUTE_LINKING);
if (is_array($linkedEntity)) {
list($path, $strategy) = each($linkedEntity);
if (!in_array($strategy, self::$linkingStrategies)) {
$strategy = $linkingStrategy;
}
} else {
$strategy = $linkingStrategy;
$path = $linkedEntity;
}
return [$path, $strategy];
}
} }

Loading…
Cancel
Save