[FEATURE] Support custom translation servers for extensions 87/22587/2
authorXavier Perseguers <xavier@typo3.org>
Fri, 26 Jul 2013 12:41:43 +0000 (14:41 +0200)
committerXavier Perseguers <xavier@typo3.org>
Sun, 28 Jul 2013 17:46:32 +0000 (19:46 +0200)
Use of signal/slot to post-process the mirror URL when fetching
localization packages for a given extension key.

Resolves: #50467
Releases: 6.2
Change-Id: I6a0edc0a6765da05458c191f968f72068132b87b
Reviewed-on: https://review.typo3.org/22587
Reviewed-by: Stefan Neufeind
Reviewed-by: BegoƱa
Reviewed-by: Frans Saris
Reviewed-by: Xavier Perseguers
Tested-by: Xavier Perseguers
typo3/sysext/lang/Classes/Service/UpdateTranslationService.php

index 3d01bc4..b3b31fb 100644 (file)
@@ -58,6 +58,12 @@ class UpdateTranslationService {
        protected $terConnection;
 
        /**
+        * @var \TYPO3\CMS\Extbase\SignalSlot\Dispatcher
+        * @inject
+        */
+       protected $signalSlotDispatcher;
+
+       /**
         * @var array
         */
        protected $translationStates = array();
@@ -115,7 +121,7 @@ class UpdateTranslationService {
                        return static::TRANSLATION_INVALID;
                }
 
-               $mirrorUrl = $this->repositoryHelper->getMirrors()->getMirrorUrl();
+               $mirrorUrl = $this->getMirrorUrl($extensionKey);
                $status = $this->terConnection->fetchTranslationStatus($extensionKey, $mirrorUrl);
 
                foreach ($selectedLanguages as $language) {
@@ -171,7 +177,7 @@ class UpdateTranslationService {
                }
 
                $state = static::TRANSLATION_FAILED;
-               $mirrorUrl = $this->repositoryHelper->getMirrors()->getMirrorUrl();
+               $mirrorUrl = $this->getMirrorUrl($extensionKey);
                $updateResult = $this->terConnection->updateTranslation($extensionKey, $locale, $mirrorUrl);
                if ($updateResult === TRUE) {
                        $state = static::TRANSLATION_UPDATED;
@@ -180,5 +186,26 @@ class UpdateTranslationService {
                return $state;
        }
 
+       /**
+        * Returns the mirror URL for a given extension.
+        *
+        * @param string $extensionKey
+        * @return string
+        */
+       protected function getMirrorUrl($extensionKey) {
+               $mirrorUrl = $this->repositoryHelper->getMirrors()->getMirrorUrl();
+
+               $this->signalSlotDispatcher->dispatch(
+                       __CLASS__,
+                       'postProcessMirrorUrl',
+                       array(
+                               'extensionKey' => $extensionKey,
+                               'mirrorUrl' => &$mirrorUrl,
+                       )
+               );
+
+               return $mirrorUrl;
+       }
+
 }
 ?>
\ No newline at end of file