[FEATURE] Support custom translation servers for extensions
[Packages/TYPO3.CMS.git] / typo3 / sysext / lang / Classes / Service / UpdateTranslationService.php
index 3d01bc4..b3b31fb 100644 (file)
@@ -57,6 +57,12 @@ class UpdateTranslationService {
         */
        protected $terConnection;
 
+       /**
+        * @var \TYPO3\CMS\Extbase\SignalSlot\Dispatcher
+        * @inject
+        */
+       protected $signalSlotDispatcher;
+
        /**
         * @var 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