@param string $translationsData

@throws Exception

@return Translations
544173
private function parseTranslations($translationsData)
    {
        $translations = Translations::fromPoString($translationsData);
        if (count($translations) < 1) {
            throw new Exception('No translations downloaded');
        }

        return $translations;
    }
619993
protected function getTranslationsStats(Translations $translations, DateTime $defaultUpdatedOn)
    {
        $result = null;
        foreach ($translations as $translation) {
            if ($translation->hasTranslation()) {
                $result = [
                    'version' => '',
                    'updatedOn' => $defaultUpdatedOn,
                ];
                break;
            }
        }
        if ($result !== null) {
            $h = $translations->getHeader('Project-Id-Version');
            if ($h && preg_match('/\s([\S]*\d[\S]*)$/', $h, $m)) {
                $result['version'] = $m[1];
            }
            $h = $translations->getHeader('PO-Revision-Date');
            if ($h) {
                try {
                    $result['updatedOn'] = new DateTime($h);
                } catch (Exception $x) {
                } catch (Throwable $x) {
                }
            }
        }

        return $result;
    }
866090
function textForFilter( $filterData )
    {
        $text = false;
        if ( isset( $this->FilterMap[$filterData['name']] ) )
        {
            $filterDefinition =& $this->FilterMap[$filterData['name']];
            $text = $this->convertFilterToText( $filterDefinition, $filterData );
        }
        return $text;
    }
804507
public function translate($text)
    {
        $translator = new Translation(new Client(), $this->config);

        return $translator->translate($text);
    }
471187
public static function decode(string $stringData): array
    {
        $decoded = json_decode($stringData, true);

        if ($decoded === null) {
            $errNo = json_last_error();
            $msg = json_last_error_msg();
            throw new Exception("Unable to decode JSON string, error ({$errNo}): {$msg}", $errNo);
        }

        return $decoded;
    }
626378
public static function convertLockAlias(array $lockData)
    {
        if (isset($lockData['aliases'])) {
            $aliases = array();

            foreach ($lockData['aliases'] as $i => $config) {
                $aliases[$config['package']][$config['version']] = array(
                    'alias' => $config['alias'],
                    'alias_normalized' => $config['alias_normalized'],
                );
            }

            $lockData['aliases'] = $aliases;
        }

        return $lockData;
    }
95197
protected function transform($data)
    {
        if (!$data instanceof GetSchema\Schema) {
            throw new Exception('Schema instance missing.');
        }

        $returnData = [];

        foreach ($data->getTableDefinitions() as $definition) {
            $tmp = self::$tplData;
            $tmp['Name'] = $tmp[0] = $definition->getName();
            $returnData[] = $tmp;
        }

        if ($this->likeExpr !== '') {
            $returnData = $this->filterData($returnData);
        }

        return array_values($returnData);
    }
1152084
public function importData(array $importData)
    {
        //@TODO przeniesienie do setDefaultImportParams
        \App\Registry::$db->query('SET FOREIGN_KEY_CHECKS = 0;');
        \App\Registry::$db->setDefaultImportParams()
            ->beginTransaction();
        //iteracja po danych z tabel
        foreach ($importData as $tableName => $data) {
            \App\Registry::$db;
            //puste dane
            if (empty($data)) {
                continue;
            }
            //czyszczenie tabeli
            \App\Registry::$db->delete($tableName);
            //wstawienie danych
            \App\Registry::$db->insertAll($tableName, $data);
        }
        //commit transakcji
        return \App\Registry::$db->commit();
    }
1141223
public static function createFromResponse($responseData)
    {
        $balance = new self();
        $balance->setRawResponseData($responseData)
            ->processResponse();

        if ($balance['status'] !== 0 && $balance['status'] !== '0') {
            throw new Exception($balance['err_msg']);
        }

        return $balance;
    }
739952
public function getTranslator($type, array $params = [])
    {
        $result = null;

        if (!isset($params['language'])) {
            throw new \Exception('Need \'language\' param');
        }
        switch ($type) {
            case interfaces\Translator::TRANSLATOR_FILE:
                $result = new FileTranslator();
                if (!isset($params['dir'])) {
                    throw new \Exception('Need \'dir\' param');
                }
                $result->setDir($params['dir']);
                $result->setLanguage($params['language']);
                break;
            case interfaces\Translator::TRANSLATOR_ARRAY:
                $result = new ArrayTranslator();
                if (!isset($params['map'])) {
                    throw new \Exception('Need \'map\' param');
                }
                $result->setMap($params['map']);
                $result->setLanguage($params['language']);
                break;
            case interfaces\Translator::TRANSLATOR_DB:
                $result = new DBTranslator();
                if (!isset($params['aliasFieldName'])) {
                    throw new \Exception('Need \'aliasFieldName\' param');
                }
                if (!isset($params['languageFieldName'])) {
                    throw new \Exception('Need \'languageFieldName\' param');
                }
                if (!isset($params['resultFieldName'])) {
                    throw new \Exception('Need \'resultFieldName\' param');
                }
                if (!isset($params['table'])) {
                    throw new \Exception('Need \'table\' param');
                }
                if (!isset($params['connection'])) {
                    throw new \Exception('Need \'connection\' param');
                }
                $result->setAliasFieldName($params['aliasFieldName']);
                $result->setResultFieldName($params['resultFieldName']);
                $result->setTableName($params['table']);
                $result->setLanguageFieldName($params['languageFieldName']);
                $result->setQueryBuilder(\pwf\basic\db\QueryBuilder::select()
                        ->setConditionBuilder(\pwf\basic\db\QueryBuilder::getConditionBuilder()));
                $result->setConnection(is_string($params['connection']) ? \pwf\basic\Application::$instance->getComponent($params['connection'])
                            : $params['connection']);
                $result->setLanguage($params['language']);
                break;
        }

        return $result;
    }
286938
private static function parseXml(\Gettext\Translations $translations, $realPath, $shownPath)
    {
        if (@filesize($realPath) !== 0) {
            $xml = new \DOMDocument();
            if ($xml->load($realPath) === false) {
                global $php_errormsg;
                if (isset($php_errormsg) && $php_errormsg) {
                    throw new \Exception("Error loading '$realPath': $php_errormsg");
                } else {
                    throw new \Exception("Error loading '$realPath'");
                }
            }
            switch ($xml->documentElement->tagName) {
                case 'concrete5-cif':
                case 'styles':
                    static::parseXmlNode($translations, $shownPath, $xml->documentElement, '');
                    break;
            }
        }
    }
800123
public function setCurrencyData(CurrencyData $currencyData)
    {
        self::$conversionMap = $currencyData->getCurrencies();
        self::$native = $currencyData->getNative();
        return $this;
    }
141150
public function getTranslations(ExportCommand $exportCommand)
    {
        $locales = $this->determineLocalesToImport($exportCommand);
        $domains = $this->determineDomainsToImport($exportCommand);

        $translations = [];
        /** @var Translation $translation */
        foreach ($this->translationRepository->getTranslationsByLocalesAndDomains($locales, $domains) as $translation) {
            // Sort by translation key.
            $translations[$translation->getKeyword()][$translation->getLocale()] = $translation;
        }

        return $translations;
    }
807374
private function getTranslationsForDomain($locale, $domain)
    {
        $allMessages = $this->getTranslationsForLocale($locale);

        if (!array_key_exists($domain, $allMessages)) {
            throw new \Exception('Domain ' . $domain . ' not found in the translations for locale ' . $locale);
        }

        return $allMessages[$domain];
    }
520185
protected function buildLanguage(array $siteData)
    {
        if (!empty($siteData['language']) && $siteData['language'] instanceof Language) {
            return $siteData['language'];
        }

        if (!empty($siteData['languageIso6392t'])) {
            $language = $this->languageRepository->findOneBy(
                ['iso639_2t' => $siteData['languageIso6392t']]
            );

            if (empty($language)) {
                throw new LanguageNotFoundException("Language {$siteData['languageIso6392t']} could not be found.");
            }

            return $language;
        }

        return null;
    }
455324
public function createEmailEventType(array $eventData)
    {
        if ($this->findEmailEventType($eventData)) {
            throw new Exception("Email event type {$eventData['EVENT_NAME']} already exists");
        }
        $et = new CEventType;
        $res = $et->add($eventData);
        if (!$res) {
            throw new Exception("Can't create email event type {$eventData['EVENT_NAME']}: {$et->LAST_ERROR}");
        }

        return ["Email event type {$eventData['EVENT_NAME']}({$res}) created"];
    }
1163920
private function updateBlockTranslations(Block $block, array $translationsData): void
    {
        $mainLocale = $block->getMainLocale();

        foreach ($block->getAvailableLocales() as $locale) {
            if ($locale === $mainLocale) {
                continue;
            }

            if (!array_key_exists($locale, $translationsData)) {
                throw new RuntimeException(
                    sprintf('Could not find locale "%s" in the given block data', $locale)
                );
            }

            $this->updateBlockTranslation($block, $translationsData[$locale], $locale);
        }
    }