Example #1
0
 /**
  * @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;
 }
Example #2
0
 public function init()
 {
     parent::init();
     $this->db = Instance::ensure($this->db, Connection::className());
 }
Example #3
0
 /**
  * @inheritdoc
  */
 public function importCollection($data)
 {
     return $this->db->transaction(function () use($data) {
         return parent::importCollection($data);
     });
 }
Example #4
0
 public function init()
 {
     parent::init();
     $this->path = Yii::getAlias($this->path . '/' . $this->module->id);
 }