コード例 #1
0
ファイル: Attribute.php プロジェクト: Bladefidz/ocfa_yii
 public function linkRelatedModel()
 {
     if (!DI::getCellParser()->isLoadedPk($this->cell)) {
         return;
     }
     $loadedPk = DI::getCellParser()->getLoadedPk($this->cell);
     foreach (array_reverse(DI::getImporter()->models) as $model) {
         $isRelatedByPk = $loadedPk && $model->savedPk == $loadedPk;
         $attributeModelClass = $this->_standardAttribute->standardModel->className;
         $modelClass = $model->standardModel->className;
         $isRelatedByLastPk = $loadedPk === '' && $attributeModelClass != $modelClass;
         if ($isRelatedByPk || $isRelatedByLastPk) {
             $this->_relatedModel = $model;
             break;
         }
     }
     if (!$this->_relatedModel) {
         throw new CellException($this->cell, 'Related model not found.');
     }
 }
コード例 #2
0
ファイル: Model.php プロジェクト: arogachev/yii2-excel
 public function validate()
 {
     if (!$this->_instance->validate()) {
         DI::getImporter()->wrongModel = $this->_instance;
         throw new RowException($this->row, 'Model data is not valid.');
     }
 }