本文整理匯總了PHP中common\models\Article::getLocaleInstance方法的典型用法代碼示例。如果您正苦於以下問題:PHP Article::getLocaleInstance方法的具體用法?PHP Article::getLocaleInstance怎麽用?PHP Article::getLocaleInstance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類common\models\Article
的用法示例。
在下文中一共展示了Article::getLocaleInstance方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: actionUpdate
/**
* Updates an existing Article model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id
* @return mixed
*/
public function actionUpdate($id)
{
$firstModel = $this->findModel($id);
foreach (Yii::$app->params['availableLocales'] as $key => $value) {
$currentModel = Article::getLocaleInstance($key);
$dataModel = $currentModel::find()->andWhere(['locale_group_id' => $firstModel->locale_group_id, 'locale' => $key])->one();
$dataModel->categoriesList = $this->getCategoriesListIds($dataModel->id);
if (!empty($dataModel->domain)) {
$dataModel->domain = explode(',', $dataModel->domain);
}
$models[$key] = $dataModel;
if (!$models[$key]) {
$currentModel->attributes = $firstModel->attributes;
$currentModel->attachments = $firstModel->attachments;
$currentModel->thumbnail = $firstModel->thumbnail;
$currentModel->image = $firstModel->image;
$currentModel->categoriesList = $firstModel->categoriesList;
//$currentModel->video = $firstModel->video;
$currentModel->locale_group_id = $firstModel->locale_group_id;
$currentModel->locale = $key;
$currentModel->title = 'title ' . $key . ' ' . time();
$currentModel->slug = '';
$models[$key] = $currentModel;
}
}
$model = new MultiModel(['models' => $models]);
if ($model->load(Yii::$app->request->post()) && Article::multiSaveUpdate($model)) {
return $this->redirect(['index']);
} else {
return $this->render('update', ['model' => $model, 'categories' => ArticleCategory::find()->active()->all(), 'domains' => array_combine(explode(',', Yii::getAlias('@frontendUrls')), explode(',', Yii::getAlias('@frontendUrls')))]);
}
}