TYPO3  7.6
LanguageCommandController.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Lang\Command;
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
19 
24 {
29 
33  protected $registryService;
34 
38  public function injectSignalSlotDispatcher(\TYPO3\CMS\Extbase\SignalSlot\Dispatcher $signalSlotDispatcher)
39  {
40  $this->signalSlotDispatcher = $signalSlotDispatcher;
41  }
42 
46  public function injectRegistryService(\TYPO3\CMS\Lang\Service\RegistryService $registryService)
47  {
48  $this->registryService = $registryService;
49  }
50 
57  public function updateCommand($localesToUpdate = '')
58  {
60  $translationService = $this->objectManager->get(\TYPO3\CMS\Lang\Service\TranslationService::class);
62  $languageRepository = $this->objectManager->get(\TYPO3\CMS\Lang\Domain\Repository\LanguageRepository::class);
63  $locales = array();
64  if (!empty($localesToUpdate)) {
65  $locales = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $localesToUpdate, true);
66  } else {
67  $languages = $languageRepository->findSelected();
68  foreach ($languages as $language) {
70  $locales[] = $language->getLocale();
71  }
72  }
74  $packageManager = $this->objectManager->get(\TYPO3\CMS\Core\Package\PackageManager::class);
76  $packages = $packageManager->getAvailablePackages();
77  $this->outputLine((sprintf('Updating language packs of all activated extensions for locales "%s"', implode(', ', $locales))));
78  $this->output->progressStart(count($locales) * count($packages));
79  foreach ($locales as $locale) {
81  foreach ($packages as $package) {
82  $extensionKey = $package->getPackageKey();
83  $result = $translationService->updateTranslation($extensionKey, $locale);
84  if (empty($result[$extensionKey][$locale]['error'])) {
85  $this->registryService->set($locale, $GLOBALS['EXEC_TIME']);
86  }
87  $this->output->progressAdvance();
88  }
89  }
90  $this->output->progressFinish();
91  }
92 
96  protected function emitPackagesMayHaveChangedSignal()
97  {
98  $this->signalSlotDispatcher->dispatch('PackageManagement', 'packagesMayHaveChanged');
99  }
100 }