TYPO3 CMS  TYPO3_7-6
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 
21 
26 {
31 
35  protected $registryService;
36 
40  public function injectSignalSlotDispatcher(\TYPO3\CMS\Extbase\SignalSlot\Dispatcher $signalSlotDispatcher)
41  {
42  $this->signalSlotDispatcher = $signalSlotDispatcher;
43  }
44 
48  public function injectRegistryService(\TYPO3\CMS\Lang\Service\RegistryService $registryService)
49  {
50  $this->registryService = $registryService;
51  }
52 
59  public function updateCommand($localesToUpdate = '')
60  {
62  $translationService = $this->objectManager->get(\TYPO3\CMS\Lang\Service\TranslationService::class);
64  $languageRepository = $this->objectManager->get(\TYPO3\CMS\Lang\Domain\Repository\LanguageRepository::class);
65  $locales = [];
66  if (!empty($localesToUpdate)) {
67  $locales = GeneralUtility::trimExplode(',', $localesToUpdate, true);
68  } else {
69  $languages = $languageRepository->findSelected();
70  foreach ($languages as $language) {
72  $locales[] = $language->getLocale();
73  }
74  }
76  $packageManager = $this->objectManager->get(\TYPO3\CMS\Core\Package\PackageManager::class);
78  $packages = $packageManager->getAvailablePackages();
79  $this->outputLine((sprintf('Updating language packs of all activated extensions for locales "%s"', implode(', ', $locales))));
80  $this->output->progressStart(count($locales) * count($packages));
81  foreach ($locales as $locale) {
83  foreach ($packages as $package) {
84  $extensionKey = $package->getPackageKey();
85  $result = $translationService->updateTranslation($extensionKey, $locale);
86  if (empty($result[$extensionKey][$locale]['error'])) {
87  $this->registryService->set($locale, $GLOBALS['EXEC_TIME']);
88  }
89  $this->output->progressAdvance();
90  }
91  }
92  // Flush language cache
93  GeneralUtility::makeInstance(CacheManager::class)->getCache('l10n')->flush();
94  $this->output->progressFinish();
95  }
96 
100  protected function emitPackagesMayHaveChangedSignal()
101  {
102  $this->signalSlotDispatcher->dispatch('PackageManagement', 'packagesMayHaveChanged');
103  }
104 }
static trimExplode($delim, $string, $removeEmptyValues=false, $limit=0)
injectRegistryService(\TYPO3\CMS\Lang\Service\RegistryService $registryService)
injectSignalSlotDispatcher(\TYPO3\CMS\Extbase\SignalSlot\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