/** * Run step. * * @param int $step * * @return bool */ public function runStep($step) { // Get settings $settings = $this->getSettings(); // Backup? if ($settings->backup && !$step) { // Do the backup $backup = new DbBackup(); $this->backupFile = $backup->run(); } // Open file $data = craft()->import->data($settings->file); // On start if (!$step) { // Fire an "onImportStart" event $event = new Event($this, array('settings' => $settings)); craft()->import->onImportStart($event); } // Check if row exists if (isset($data[$step])) { // Import row craft()->import->row($step, $data[$step], $settings); } // When finished if ($step == $settings->rows - 1) { // Finish craft()->import->finish($settings, $this->backupFile); // Fire an "onImportFinish" event $event = new Event($this, array('settings' => $settings)); craft()->import->onImportFinish($event); } return true; }
/** * @return bool|string */ public function backup() { $backup = new DbBackup(); if (($backupFile = $backup->run()) !== false) { return $backupFile; } return false; }
/** * Performs a database backup. * * @param array|null $ignoreDataTables If set to an empty array, a full database backup will be performed. If set * to an array or database table names, they will get merged with the default * list of table names whose data is to be ignored during a database backup. * * @return bool|string The file path to the database backup, or false if something went wrong. */ public function backup($ignoreDataTables = null) { $backup = new DbBackup(); if ($ignoreDataTables !== null) { $backup->setIgnoreDataTables($ignoreDataTables); } if (($backupFile = $backup->run()) !== false) { return $backupFile; } return false; }
/** * Performs a database backup. * * @param array|null $ignoreDataTables If set to an empty array, a full database backup will be performed. If set * to an array or database table names, they will get merged with the default * list of table names whose data is to be ignored during a database backup. * * @return bool|string The file path to the database backup, or false if something went wrong. */ public function backup($ignoreDataTables = null) { $backup = new DbBackup(); if ($ignoreDataTables !== null) { $backup->setIgnoreDataTables($ignoreDataTables); } if (($backupFile = $backup->run()) !== false) { // Fire an 'onBackup' event $this->onBackup(new Event($this, array('filePath' => $backupFile))); return $backupFile; } return false; }