/
v.bolshakov
/
AIEcosystem-Testing
Обзор
Документация
Войти
/
v.bolshakov
/
AIEcosystem-Testing
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
dev
common/kdf/KLanguageQuery.php
114 строк
3 KB
Developer
Initial commit
03 авг 2026, 17:43
03 авг 2026, 17:43
7433917
Код
Авторство
О чём код?
<?php namespace common\kdf; use common\interfaces\TitleOrderInterface; use common\kdf\base\PerevodKdfQuery; use common\models\ClientLanguage; use common\models\Rate; use common\models\Service; use common\traits\TitleQueryTrait; use yii\helpers\ArrayHelper; /** * Классификатор - языки * * @author Dmitry E. Semenov <sde.tomsk@gmail.com> * @copyright Self (c) 2019-2021 */ class KLanguageQuery extends PerevodKdfQuery implements TitleOrderInterface { use TitleQueryTrait; /** * Пересечение по расценкам * * @param string $direcion_key * @param array $params * @return $this */ public function prepareRate($direcion_key, $params = []) { $a = $this->alias; $vendor_id = ArrayHelper::getValue($params, 'vendor_id'); if ($vendor_id) { $rate = Rate::find() ->prepareProject( ArrayHelper::getValue($params, 'project_id'), $vendor_id ); $this ->alias($a) ->innerJoin(['r' => $rate], $a . '.id = r.' . $direcion_key) ->andFilterWhere([ 'r.currency_id' => ArrayHelper::getValue($params, 'currency_id'), 'r.source_language_id' => ArrayHelper::getValue($params, 'source_language_id'), 'r.unit_id' => ArrayHelper::getValue($params, 'unit_id'), 'r.service_id' => ArrayHelper::getValue($params, 'service_id'), ]); if ($client_id = ArrayHelper::getValue($params, 'client_id')) { $this ->innerJoin(['s' => Service::tableName()], 's.id = r.service_id') ->andWhere([ 'client_id' => $client_id ]); } } return $this; } /** * Выбрать языки клиента * * @param $client_id * @param int $direction_id * @param null $express_available * @return KLanguageQuery */ public function prepareClient($client_id, $direction_id = KDirection::SOURCE, $express_available = null) { $a = $this->alias; return $this ->alias($a) ->innerJoin(['cl' => ClientLanguage::tableName()], $a . '.id = cl.language_id') ->andFilterWhere([ 'client_id' => $client_id, 'direction_id' => $direction_id, 'express_available' => $express_available, ]); } /** * Выбрать языки которые можно использовать в MT * @param $direction_id * @throws \yii\base\InvalidConfigException */ public function prepareMt($direction_id = KDirection::SOURCE) { $sub = SLanguageDirection::find() ->select('language_id') ->andWhere([ 'direction_id' => $direction_id, 'driver_id' => [ KSystem::DEEPL, KSystem::YANDEX, KSystem::GOOGLE, KSystem::MODERNMT, ] ]); $a = $this->alias; return $this ->alias($a) ->andWhere([ $a . '.id' => $sub ]); } }