public function tearDown() { if ($this->tmpDir != '' && is_dir($this->tmpDir)) { Directory::delete($this->tmpDir, true); } parent::tearDown(); }
public static function tearDownAfterClass() { $genPath = Di::getDefault()->get('config')->get('global', 'centreon_generate_tmp_dir'); if ($genPath != "" && is_dir($genPath)) { Directory::delete($genPath, true); } parent::tearDownAfterClass(); }
/** * * @param type $moduleName */ public static function remove($moduleName) { $path = rtrim(Di::getDefault()->get('config')->get('global', 'centreon_path'), '/'); $sourceModuleStaticFilesPath = $path . '/www/static/' . $moduleName; Directory::delete($sourceModuleStaticFilesPath, true); }
/** * * @param string $targetDbName */ private static function deleteTargetDbSchema($targetDbName = 'centreon') { // Initialize configuration $di = Di::getDefault(); $config = $di->get('config'); $centreonPath = $config->get('global', 'centreon_generate_tmp_dir'); $targetFolder = $centreonPath . '/tmp/db/target/' . $targetDbName . '/'; $currentFolder = $centreonPath . '/tmp/db/current/' . $targetDbName . '/'; // Copy to destination if (!file_exists($currentFolder)) { mkdir($currentFolder, 0775, true); if (posix_getuid() == 0) { chown($currentFolder, 'centreon'); chgrp($currentFolder, 'centreon'); } } $fileList = glob($targetFolder . '/*.xml'); $nbOfFiles = count($fileList); for ($i = 0; $i < $nbOfFiles; $i++) { $targetFile = $currentFolder . basename($fileList[$i]); copy($fileList[$i], $targetFile); if (posix_getuid() == 0) { chmod($targetFile, 0664); chown($targetFile, 'centreon'); chgrp($targetFile, 'centreon'); } unlink($fileList[$i]); } Directory::delete($targetFolder, true); }
/** * * @param string $module */ public function __construct($module = 'centreon') { $this->module = $module; $this->di = Di::getDefault(); $this->appConfig = $this->di->get('config'); $this->propelConfiguration['datasources'] = array('centreon' => array('adapter' => 'mysql', 'connection' => array('dsn' => $this->appConfig->get($this->targetDb, 'dsn'), 'user' => $this->appConfig->get($this->targetDb, 'username'), 'password' => $this->appConfig->get($this->targetDb, 'password')))); $this->appPath = rtrim(Di::getDefault()->get('config')->get('global', 'centreon_path'), '/'); $this->tmpDir = rtrim($this->appConfig->get('global', 'centreon_generate_tmp_dir'), '/') . '/' . $this->module . '/propel'; if (file_exists($this->tmpDir)) { Directory::delete($this->tmpDir, true); } mkdir($this->tmpDir, 0700, true); mkdir($this->tmpDir . '/schema/', 0700, true); $this->propelPath = $this->appPath . '/vendor/propel/propel1/'; $this->outputDir = $this->tmpDir . '/output/'; $this->mySchemaBuilder = new SchemaBuilder('centreon', $this->tmpDir . '/schema/', $module); }