コード例 #1
0
 /**
  * Ищет перевод по метрике и языку. Если не находит, создает новый с названием оригинала
  * @param int $metric_id
  * @param int $lang_id
  * @return array
  */
 public static function getTranslation($metric_id, $lang_id)
 {
     $translation = self::findOne(['feature_metric_id' => $metric_id, 'language_id' => $lang_id]);
     if (!$translation) {
         $original_name = FeaturesMetrics::find()->select('feature_metric')->where(['id' => $metric_id])->scalar();
         $translation = new self();
         $translation->metric_translation = $original_name;
         $translation->feature_metric_id = $metric_id;
         $translation->language_id = $lang_id;
         $translation->save();
     }
     return $translation->toArray();
 }
コード例 #2
0
 public function actionTypes()
 {
     $current_mode = 1;
     if (Yii::$app->request->get('mode')) {
         $current_mode = Yii::$app->request->get('mode');
     }
     $features_types_model = new FeaturesTypes();
     if ($features_types_model->load(Yii::$app->request->post())) {
         $features_types_model->add();
     }
     $features_query = Features::find();
     $pages = new Pagination(['totalCount' => $features_query->count()]);
     $pages->setPageSize(Features::FEATURES_PER_PAGE);
     $features_list = $features_query->offset($pages->offset)->limit($pages->limit)->asArray()->all();
     return $this->render('types', ['metrics_list' => FeaturesMetrics::find()->asArray()->all(), 'features_types_model' => $features_types_model, 'features_list' => $features_list, 'current_mode' => $current_mode, 'features_synonims' => FeaturesSynonims::getUnsorted(), 'pages' => $pages]);
 }