From d52927fe07b39f756489f86b2f43fce30f0fbf98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BD=D0=B4=D1=80=D0=B5=D0=B9=20=D0=9A=D0=BE=D0=BB?= =?UTF-8?q?=D1=87=D0=B5=D0=BD=D0=BA=D0=BE?= Date: Wed, 5 Nov 2014 16:39:43 +0300 Subject: [PATCH] Get path and strategy. --- .../Filesystem/LinkSharedFilesTask.php | 30 ++++++++++++++----- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/Mage/Task/BuiltIn/Filesystem/LinkSharedFilesTask.php b/Mage/Task/BuiltIn/Filesystem/LinkSharedFilesTask.php index 16eb289..d457d4d 100644 --- a/Mage/Task/BuiltIn/Filesystem/LinkSharedFilesTask.php +++ b/Mage/Task/BuiltIn/Filesystem/LinkSharedFilesTask.php @@ -35,7 +35,7 @@ class LinkSharedFilesTask extends AbstractTask implements IsReleaseAware /** * @var array */ - public $linkingStrategies = array( + private static $linkingStrategies = array( self::ABSOLUTE_LINKING, self::RELATIVE_LINKING ); @@ -77,12 +77,7 @@ class LinkSharedFilesTask extends AbstractTask implements IsReleaseAware $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; - } + list($entityPath, $strategy) = $this->getPath($ePath); $sharedEntityLinkedPath = "$sharedFolderPath/$entityPath"; if ($strategy == self::RELATIVE_LINKING) { $parentFolderPath = dirname($entityPath); @@ -98,4 +93,25 @@ class LinkSharedFilesTask extends AbstractTask implements IsReleaseAware 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]; + } }