/**
  * Handles Creation of SheetRecordParserAbstract
  * 
  * @param array $impData Import config data as given by the user. 
  * {@see SelectSheetForm}
  * @param array $file    The File, with the sheet data. $fileName['tmp_name']
  * 
  * @return array Numeric indexed, with a an instance of 
  * SheetRecordParserAbstract in index 0 and an instance of sfImportSheetRecordForm
  * in index 1. array(SheetRecordParserAbstract, sfImportSheetRecordForm)
  */
 private function configureImport($impData, $file)
 {
     $sheets = Config::get('sheets');
     $record = $sheets[$impData['sheet']]['records'][$impData['record']];
     $recordParser = SheetRecordParserAbstract::getInstance($file, $impData['file_type'], $record, $impData['delimiter']);
     return $recordParser;
 }
 /**
  * For each Record returned by the parser, try to assign it to the proper
  * entity. Also takes care of populating defaults found in importSchema
  * configuration.
  * 
  * @param SheetRecordParserAbstract $recordParser             An instanse of
  * SheetRecordParserAbstract already associated to the input file to be parsed.
  * @param sfImportSheetRecordForm   $sheetForm                The sheetForm 
  * used for validation it should be already initialized by the action.
  * @param array                     $onErrorBehavior          Controls how to 
  * react to errors. Optional, defaults to null.
  * @param bool                      $onErrorDisplayExceptions Define if 
  * display exceptions when an error ocurred. 
  * 
  * @return array With error messages.
  * @see self::$_onErrorBehavior
  */
 public static function populateEntities(SheetRecordParserAbstract $recordParser, $onErrorBehavior = null, $onErrorDisplayExceptions = null)
 {
     self::handleExecutionTime();
     self::_loadErrorConfig($onErrorBehavior, $onErrorDisplayExceptions);
     $recordDef = $recordParser->getSheetRecordDefinition();
     //self::$conn->transaction->setIsolation('READ UNCOMMITTED');
     try {
         foreach ($recordParser as $sheetRecord) {
             // We are not validating input. if we did, sfForms are missing.
             //                 $validatedVals = self::validateSheetRecord($sheetRecord);
             // if (null === $validatedVals) {
             //     continue;
             // }
             $validatedVals = self::normalizeValues($sheetRecord);
             $entVals = self::splitValuesForEntity($validatedVals, $recordDef);
             self::loadEntityDefaultValues($entVals, $recordDef);
             try {
                 $entities = self::loadEntities($entVals, $recordDef);
                 //                    self::relateEntities($entities, $recordDef);
                 self::saveEntities($entities, $recordParser);
             } catch (MethodNotImplementedException $e) {
                 // BOOM! prevent next catch to hide this.
                 throw $e;
             } catch (Exception $e) {
                 self::handlePopulationError($e, $validatedVals, $entities);
             }
         }
     } catch (sfFileException $e) {
         if (true == self::$_onErrorDisplayExceptions) {
             throw $e;
         }
     }
     self::handleExecutionTime(true);
     return self::$_errors;
 }