本文整理汇总了PHP中Actions::addError方法的典型用法代码示例。如果您正苦于以下问题:PHP Actions::addError方法的具体用法?PHP Actions::addError怎么用?PHP Actions::addError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Actions
的用法示例。
在下文中一共展示了Actions::addError方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: reconstructImportedActionAssoc
/**
* Handle reconstructing and validating Action associations
* @param Action $model Action to reconstruct association
*/
protected function reconstructImportedActionAssoc(Actions &$model)
{
$exportableModules = array_merge(array_keys(Modules::getExportableModules()), array('None'));
$exportableModules = array_map('lcfirst', $exportableModules);
$model->associationType = lcfirst($model->associationType);
if (!in_array($model->associationType, $exportableModules)) {
// Invalid association type
$model->addError('associationType', Yii::t('admin', 'Unknown associationType.'));
} else {
if (isset($model->associationId) && $model->associationId !== '0') {
$associatedModel = X2Model::model($model->associationType)->findByPk($model->associationId);
if ($associatedModel) {
$model->associationName = $associatedModel->nameId;
}
} else {
if (!isset($model->associationId) && isset($model->associationName)) {
// Retrieve associationId
$staticAssociationModel = X2Model::model($model->associationType);
if ($staticAssociationModel->hasAttribute('name') && !ctype_digit($model->associationName)) {
$associationModelParams = array('name' => $model->associationName);
} else {
$associationModelParams = array('id' => $model->associationName);
}
$lookup = $staticAssociationModel->findByAttributes($associationModelParams);
if (isset($lookup)) {
$model->associationId = $lookup->id;
$model->associationName = $lookup->hasAttribute('nameId') ? $lookup->nameId : $lookup->name;
}
}
}
}
}