protected function getLanguages()
 {
     return Yii::$app->cache->getAuthTimeCached(86400, [], function () {
         // 1d
         $result = [];
         $templates = Template::find()->joinWith('texts')->all();
         foreach (ArrayHelper::getColumn($templates, 'texts') as $texts) {
             foreach ($texts as $text) {
                 $result[$text->lang] = ['name' => Yii::t('hipanel', $text->lang), 'code' => $text->lang];
             }
         }
         return $result;
     });
 }
 public function actionText($id, $lang)
 {
     Yii::$app->response->format = Response::FORMAT_JSON;
     $result = [];
     try {
         $template = Template::find()->joinWith('texts')->andWhere(['id' => $id])->one();
     } catch (ErrorResponseException $e) {
         return [];
     }
     if (isset($template->texts)) {
         foreach ($template->texts as $text) {
             if ($text->lang === $lang) {
                 $result['text'] = $text->text;
             }
         }
     }
     return $result;
 }