/** * @param Storage $storage * @return integer|false */ public function save(Storage $storage) { if (!$this->validate()) { return false; } $content = file_get_contents($this->dataFile->tempName); try { $data = Json::decode($content); } catch (InvalidParamException $e) { $this->addError('dataFile', 'Json parser: ' . $e->getMessage()); return false; } try { $count = $storage->importCollection($data); } catch (InvalidParamException $e) { $this->addError('dataFile', 'Import: ' . $e->getMessage()); return false; } return $count; }
public function init() { parent::init(); $this->db = Instance::ensure($this->db, Connection::className()); }
/** * @inheritdoc */ public function importCollection($data) { return $this->db->transaction(function () use($data) { return parent::importCollection($data); }); }
public function init() { parent::init(); $this->path = Yii::getAlias($this->path . '/' . $this->module->id); }