/** * @inheritdoc */ protected function fillModels($rows) { $c = 1; foreach ($rows as $row) { if (PHPExcelHelper::isRowEmpty($row)) { break; } if ($c == 1) { if (!$this->_standardModels[0]->parseAttributeNames($row)) { throw new RowException($row, 'Attribute names must be placed in first filled row.'); } } else { $this->_models[] = new Model(['row' => $row, 'standardModel' => $this->_standardModels[0]]); } $c++; } }
/** * @inheritdoc */ protected function fillModels($rows) { foreach ($rows as $row) { // Skipping completely empty rows // Only loaded pk links can be empty $isRowEmpty = PHPExcelHelper::isRowEmpty($row); $row->getCellIterator()->rewind(); $currentCell = $row->getCellIterator()->current(); if (!$row->getCellIterator()->valid()) { continue; } if ($isRowEmpty && !$this->_cellParser->isLoadedPk($currentCell)) { continue; } if ($this->_cellParser->isLoadedRows($currentCell)) { $this->fillModels($this->_savedRows[$this->_cellParser->getLoadedRows($currentCell)]); continue; } if ($this->_cellParser->isSavedRows($currentCell)) { if ($this->_currentSavedRow) { $this->_currentSavedRow = null; } else { $this->_currentSavedRow = $this->_cellParser->getSavedRows($currentCell); } continue; } if ($this->_currentSavedRow) { $this->_savedRows[$this->_currentSavedRow][] = clone $row; continue; } if ($this->_cellParser->isModelDefaultsLabel($currentCell)) { $this->_currentMode = self::MODE_DEFAULT_ATTRIBUTES; $this->fillCurrentStandardModel($currentCell); continue; } if ($this->_cellParser->isModelLabel($currentCell)) { $this->_currentMode = self::MODE_IMPORT; $this->fillCurrentStandardModel($currentCell); continue; } if (!$this->_currentStandardModel) { throw new RowException($row, 'Model label must be declared before attribute names or values'); } if ($this->_cellParser->isAttributeName($currentCell)) { $this->_currentStandardModel->parseAttributeNames($row); continue; } if ($this->_currentMode == self::MODE_IMPORT) { $this->_models[] = new Model(['row' => $row, 'standardModel' => $this->_currentStandardModel]); } elseif ($this->_currentMode == self::MODE_DEFAULT_ATTRIBUTES) { $this->_currentStandardModel->setDefaultAttributes($row); } } }