TYPO3 CMS  TYPO3_8-7
LanguageCommandController.php
Go to the documentation of this file.
1 <?php
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 
26 
31 {
36 
40  protected $registryService;
41 
46  {
47  $this->signalSlotDispatcher = $signalSlotDispatcher;
48  }
49 
54  {
55  $this->registryService = $registryService;
56  }
57 
63  public function updateCommand($localesToUpdate = '')
64  {
66  $translationService = $this->objectManager->get(TranslationService::class);
68  $languageRepository = $this->objectManager->get(LanguageRepository::class);
69  $locales = [];
70  if (!empty($localesToUpdate)) {
71  $locales = GeneralUtility::trimExplode(',', $localesToUpdate, true);
72  } else {
73  $languages = $languageRepository->findSelected();
74  foreach ($languages as $language) {
76  $locales[] = $language->getLocale();
77  }
78  }
80  $packageManager = $this->objectManager->get(PackageManager::class);
82  $packages = $packageManager->getAvailablePackages();
83  $this->outputLine((sprintf('Updating language packs of all activated extensions for locales "%s"', implode(', ', $locales))));
84  $this->output->progressStart(count($locales) * count($packages));
85  foreach ($locales as $locale) {
87  foreach ($packages as $package) {
88  $extensionKey = $package->getPackageKey();
89  $result = $translationService->updateTranslation($extensionKey, $locale);
90  if (empty($result[$extensionKey][$locale]['error'])) {
91  $this->registryService->set($locale, $GLOBALS['EXEC_TIME']);
92  }
93  $this->output->progressAdvance();
94  }
95  }
96  // Flush language cache
97  GeneralUtility::makeInstance(CacheManager::class)->getCache('l10n')->flush();
98  $this->output->progressFinish();
99  }
100 
104  protected function emitPackagesMayHaveChangedSignal()
105  {
106  $this->signalSlotDispatcher->dispatch('PackageManagement', 'packagesMayHaveChanged');
107  }
108 }
static trimExplode($delim, $string, $removeEmptyValues=false, $limit=0)
static makeInstance($className,... $constructorArguments)
injectSignalSlotDispatcher(Dispatcher $signalSlotDispatcher)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']
$locales
Definition: be_users.php:6