Cake\ORM\Behavior\TranslateBehavior::findTranslations PHP Метод

findTranslations() публичный Метод

Fetched translations can be filtered by locale by passing the locales key in the options array. Translated values will be found for each entity under the property _translations, containing an array indexed by locale name. ### Example: $article = $articles->find('translations', ['locales' => ['eng', 'deu'])->first(); $englishTranslatedFields = $article->get('_translations')['eng']; If the locales array is not passed, it will bring all translations found for each record.
public findTranslations ( Query $query, array $options ) : Query
$query Cake\ORM\Query The original query to modify
$options array Options
Результат Cake\ORM\Query
    public function findTranslations(Query $query, array $options)
    {
        $locales = isset($options['locales']) ? $options['locales'] : [];
        $targetAlias = $this->_translationTable->alias();
        return $query->contain([$targetAlias => function ($q) use($locales, $targetAlias) {
            if ($locales) {
                $q->where(["{$targetAlias}.locale IN" => $locales]);
            }
            return $q;
        }])->formatResults([$this, 'groupTranslations'], $query::PREPEND);
    }