/** * Test * * @return void */ public function testCopyDirectory() { $source = __DIR__ . '/_files/copy/source'; $destination = __DIR__ . '/_files/copy/destination'; $this->assertTrue($this->object->copyDirectory($source, $destination)); `rm -rf {$destination}`; }
/** * Upgrade * * @return boolean */ public function upgrade() { $backupFilename = $this->getTmpPath() . '/backup.zip'; //Remove old backup if (file_exists($backupFilename)) { unlink($backupFilename); } if (File::isWritable(GC_APPLICATION_PATH, array(GC_APPLICATION_PATH . '/data/cache', GC_APPLICATION_PATH . '/.git'))) { if ($this->createBackup($backupFilename)) { foreach (array('library', 'module', 'vendor', 'tests') as $directory) { $this->addMessage(sprintf('Remove %s directory', GC_APPLICATION_PATH . '/' . $directory)); File::removeDirectory(GC_APPLICATION_PATH . '/' . $directory); } $directory = $this->getTmpPath() . '/v' . $this->getLatestVersion(); $this->addMessage(sprintf('Copy %s to %s', $directory, GC_APPLICATION_PATH)); File::copyDirectory($directory, GC_APPLICATION_PATH); $this->addMessage('Done!'); return true; } } $this->addMessage('Some files are not writable!'); $this->addMessage(sprintf('Please execute: chmod -R ug+rw %s', GC_APPLICATION_PATH)); return false; }
/** * Insert data into database * * @param \Zend\Db\Adapter\Adapter $dbAdapter Database adapter * @param string $template Template name * @param string $sqlType Sql database type * * @return \Zend\View\Model\JsonModel|null */ protected function installTemplate($dbAdapter, $template, $sqlType) { $templatePath = GC_APPLICATION_PATH . sprintf('/data/install/design/%s', $template); $info = new Info(); $info->fromFile($templatePath . '/design.info'); $filePath = sprintf('%s/sql/%s.sql', $templatePath, $sqlType); if (!file_exists($filePath)) { return $this->returnJson(array('success' => false, 'message' => sprintf('Could not find data for this template and driver: Driver %s, path %s', $sqlType, $templatePath))); } $designInfos = $info->getInfos(); if (!empty($designInfos['modules'])) { $modules = $this->getServiceLocator()->get('CustomModules'); foreach ($designInfos['modules'] as $module) { ModuleModel::install($modules, $module); } } $sql = file_get_contents($filePath); $dbAdapter->getDriver()->getConnection()->getResource()->exec($sql); File::copyDirectory($templatePath . '/frontend', GC_PUBLIC_PATH . '/frontend'); if (file_exists($templatePath . '/files')) { File::copyDirectory($templatePath . '/files', GC_MEDIA_PATH . '/files'); } File::copyDirectory($templatePath . '/templates', GC_APPLICATION_PATH . '/templates'); }