Exemple #1
0
 public function tearDown()
 {
     if (is_dir($this->oc_controller_dir)) {
         $this->fsh->rmdir($this->oc_controller_dir);
     }
     $this->installer->removeDatabase($this->options);
     $this->installer->removeConfigFiles();
 }
Exemple #2
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if (parent::execute($input, $output)) {
         $file_system_helper = new FileSystem();
         $this->loadOCConfig();
         $this->backup_folder = $this->getOCDirectory() . DIRECTORY_SEPARATOR . ".backup_tmp/";
         $za = new \ZipArchive();
         if ($za->open("ocok_backup_" . date("Y_m_d_H_i") . ".zip", \ZipArchive::OVERWRITE)) {
             if (is_dir($this->backup_folder)) {
                 $file_system_helper->rmdir($this->backup_folder);
             }
             mkdir($this->backup_folder);
             $image_path = DIR_IMAGE;
             if ($this->isVersion('2')) {
                 $image_path .= 'catalog/';
             } elseif ($this->isVersion('1')) {
                 $image_path .= 'data/';
             }
             if ($input->getOption("images")) {
                 $files = $file_system_helper->getFilesRecursively($image_path);
                 foreach ($files as $file) {
                     if ($file->isFile() && $file->isReadable() && $file_system_helper->isImage($file->getPathname())) {
                         // remove basefolder prefix from path
                         if (substr($file->getPathname(), 0, strlen($this->getOCDirectory())) == $this->getOCDirectory()) {
                             $path = substr($file->getPathname(), strlen($this->getOCDirectory()));
                         }
                         $za->addFile($file->getPathname(), substr($path, 1));
                     }
                 }
             }
             if ($input->getOption("database")) {
                 $dumper = new Mysqldump(DB_DATABASE, DB_USERNAME, DB_PASSWORD, DB_HOSTNAME, 'mysql', array('add-drop-table' => true, 'add-drop-database' => true, 'databases' => true));
                 $dumper->start($this->backup_folder . $this->backup_db);
                 $za->addFile($this->backup_folder . $this->backup_db, $this->backup_db);
             }
             $za->close();
             $file_system_helper->rmdir($this->backup_folder);
         }
     }
 }