当前位置: 首页>>代码示例>>PHP>>正文


PHP FileHelper::copyDirectory方法代码示例

本文整理汇总了PHP中yii\helpers\FileHelper::copyDirectory方法的典型用法代码示例。如果您正苦于以下问题:PHP FileHelper::copyDirectory方法的具体用法?PHP FileHelper::copyDirectory怎么用?PHP FileHelper::copyDirectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在yii\helpers\FileHelper的用法示例。


在下文中一共展示了FileHelper::copyDirectory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionIndex

 public function actionIndex()
 {
     $src = DOCGEN_PATH . '/swagger-ui/';
     $dst = Yii::getAlias('@app') . '/web/apidoc/';
     FileHelper::copyDirectory($src, $dst);
     return Controller::EXIT_CODE_NORMAL;
 }
开发者ID:jiangrongyong,项目名称:docgen,代码行数:7,代码来源:PublishController.php

示例2: publishDirectory

 /**
  * (non-PHPdoc)
  * EXTRA: 
  * @see \yii\web\AssetManager::publishDirectory()
  * 
  *  [const-dir] contain directory name or empty if copy current asset directly to base assets' dir 
  */
 public function publishDirectory($src, $options)
 {
     throw new \yii\base\Exception('works but block support until it will be required. skip testing purpose');
     // default behavior with hashed dir
     if (!isset($options['const-dir'])) {
         return parent::publishDirectory($src, $options);
     }
     //
     // my custom : don't generate random dir, instead, use custom if set
     //
     $dstDir = $this->basePath . (!empty($options['const-dir']) ? '/' . $options['const-dir'] : '');
     //dont copy if already was copied
     // TODO: add datetime checks
     if (file_exists($dstDir)) {
         return [$dstDir, $this->baseUrl];
     }
     // A. copy only subdirs if set
     if (!empty($options['sub-dirs']) && is_array($options['sub-dirs'])) {
         foreach ($options['sub-dirs'] as $subdir) {
             if (is_dir($src . '/' . $subdir)) {
                 FileHelper::copyDirectory($src . '/' . $subdir, $dstDir . '/' . $subdir, ['dirMode' => $this->dirMode, 'fileMode' => $this->fileMode, 'beforeCopy' => @$options['beforeCopy'], 'afterCopy' => @$options['afterCopy'], 'forceCopy' => @$options['forceCopy']]);
             }
             //TODO: else write error log
         }
     } else {
         //copy whole dir
         FileHelper::copyDirectory($src, $dstDir, ['dirMode' => $this->dirMode, 'fileMode' => $this->fileMode, 'beforeCopy' => @$options['beforeCopy'], 'afterCopy' => @$options['afterCopy'], 'forceCopy' => @$options['forceCopy']]);
     }
     return [$dstDir, $this->baseUrl];
 }
开发者ID:yurii-github,项目名称:yii2-mylib,代码行数:37,代码来源:AssetManager.php

示例3: actionIndex

 /**
  * Renders API documentation files
  * @param array $sourceDirs
  * @param string $targetDir
  * @return int
  */
 public function actionIndex(array $sourceDirs, $targetDir)
 {
     $renderer = $this->findRenderer($this->template);
     $targetDir = $this->normalizeTargetDir($targetDir);
     if ($targetDir === false || $renderer === false) {
         return 1;
     }
     $renderer->guideUrl = './';
     // setup reference to apidoc
     if ($this->apiDocs !== null) {
         $renderer->apiUrl = $this->apiDocs;
         $renderer->apiContext = $this->loadContext($this->apiDocs);
     } elseif (file_exists($targetDir . '/cache/apidoc.data')) {
         $renderer->apiUrl = './';
         $renderer->apiContext = $this->loadContext($targetDir);
     } else {
         $renderer->apiContext = new Context();
     }
     $this->updateContext($renderer->apiContext);
     // search for files to process
     if (($files = $this->searchFiles($sourceDirs)) === false) {
         return 1;
     }
     $renderer->controller = $this;
     $renderer->render($files, $targetDir);
     $this->stdout('Publishing images...');
     foreach ($sourceDirs as $source) {
         FileHelper::copyDirectory(rtrim($source, '/\\') . '/images', $targetDir . '/images');
     }
     $this->stdout('done.' . PHP_EOL, Console::FG_GREEN);
 }
开发者ID:aivavic,项目名称:yii2,代码行数:37,代码来源:GuideController.php

示例4: registerAssetFiles

 public function registerAssetFiles($view)
 {
     parent::registerAssetFiles($view);
     // Копируем картинки
     $manager = $view->getAssetManager();
     $dst = $manager->getAssetUrl($this, 'bootstrap/css/images');
     $src = __DIR__ . '/assets/bootstrap/css/images';
     FileHelper::copyDirectory($src, $dst);
 }
开发者ID:andriell,项目名称:yii2-extensions,代码行数:9,代码来源:JqGridAsset.php

示例5: actionIndex

 public function actionIndex($environment)
 {
     $directory = \Yii::$app->basePath . '/environments/' . $environment;
     if (file_exists($directory)) {
         FileHelper::copyDirectory($directory, \Yii::$app->basePath);
         echo Console::renderColoredString('%g' . \Yii::t('app.console', 'Окружение успешно сменено на {env}', ['env' => $environment]), true);
         echo Console::renderColoredString("%n\n");
     } else {
         throw new Exception(\Yii::t('app.console', 'Указанного окружения не существует'));
     }
 }
开发者ID:vollossy,项目名称:app-template,代码行数:11,代码来源:EnvironmentController.php

示例6: run

 /**
  * @inheritdoc
  */
 public function run(&$cmdParams, &$params)
 {
     $res = true;
     $taskRunner = $this->taskRunner;
     $toBeCopied = [];
     $srcDirList = !empty($cmdParams[0]) ? $cmdParams[0] : [];
     $destDir = !empty($cmdParams[1]) ? $taskRunner->parsePath($cmdParams[1]) : '';
     $srcBaseDir = !empty($cmdParams[2]) ? $taskRunner->parsePath($cmdParams[2]) : '';
     $options = !empty($cmdParams[3]) ? $cmdParams[3] : [];
     if (empty($srcDirList) || empty($destDir)) {
         throw new Exception('copyDir: Base and destination cannot be empty');
     }
     if (!empty($srcBaseDir) && !is_dir($srcBaseDir) || file_exists($destDir) && !is_dir($destDir)) {
         throw new Exception('copyDir: Base and destination have to be directories');
     }
     // if srcDirList is specified but it is a string, we convert it to an array
     if (!empty($srcDirList) && is_string($srcDirList)) {
         $srcDirList = explode(',', $srcDirList);
     }
     foreach ($srcDirList as $dirPath) {
         $parsedPath = $taskRunner->parseStringAliases(trim($dirPath));
         if (!empty($srcBaseDir)) {
             $toBeCopied[$parsedPath] = $srcBaseDir . DIRECTORY_SEPARATOR . $parsedPath;
         } else {
             $toBeCopied[] = $parsedPath;
         }
     }
     foreach ($toBeCopied as $srcRelPath => $srcDirPath) {
         if (is_dir($srcDirPath)) {
             /* *
              * if the destination directory already exists or if we are
              * copying more than one directory, we copy the source directory inside
              * of the destination directory instead of replacing the destination
              * directory with it
              * */
             $destDirPath = $destDir;
             if (is_dir($destDirPath) || count($toBeCopied) > 1) {
                 $srcRelPath = !empty($srcBaseDir) ? $srcRelPath : basename($srcDirPath);
                 $destDirPath = $destDir . DIRECTORY_SEPARATOR . $srcRelPath;
             }
             $this->controller->stdout("Copy directory: \n  " . $srcDirPath . " to \n  " . $destDirPath);
             if (!$this->controller->dryRun) {
                 FileHelper::copyDirectory($srcDirPath, $destDirPath, $options);
             } else {
                 $this->controller->stdout(' [dry run]', Console::FG_YELLOW);
             }
             $this->controller->stdout("\n");
         } else {
             $this->controller->stderr("{$srcDirPath} is not a directory!\n", Console::FG_RED);
         }
     }
     return $res;
 }
开发者ID:giovdk21,项目名称:deployii,代码行数:56,代码来源:CopyDirCommand.php

示例7: actionIndex

 /**
  * Renders API documentation files
  * @param array $sourceDirs
  * @param string $targetDir
  * @return int
  */
 public function actionIndex(array $sourceDirs, $targetDir)
 {
     $renderer = $this->findRenderer($this->template);
     $targetDir = $this->normalizeTargetDir($targetDir);
     if ($targetDir === false || $renderer === false) {
         return 1;
     }
     if ($this->pageTitle !== null) {
         $renderer->pageTitle = $this->pageTitle;
     }
     if ($renderer->guideUrl === null) {
         $renderer->guideUrl = './';
     }
     $renderer->guidePrefix = $this->guidePrefix;
     // setup reference to apidoc
     if ($this->apiDocs !== null) {
         $path = $this->apiDocs;
         if ($renderer->apiUrl === null) {
             $renderer->apiUrl = $path;
         }
         // use relative paths relative to targetDir
         if (strncmp($path, '.', 1) === 0) {
             $renderer->apiContext = $this->loadContext("{$targetDir}/{$path}");
         } else {
             $renderer->apiContext = $this->loadContext($path);
         }
     } elseif (file_exists($targetDir . '/cache/apidoc.data')) {
         if ($renderer->apiUrl === null) {
             $renderer->apiUrl = './';
         }
         $renderer->apiContext = $this->loadContext($targetDir);
     } else {
         $renderer->apiContext = new Context();
     }
     $this->updateContext($renderer->apiContext);
     // search for files to process
     if (($files = $this->searchFiles($sourceDirs)) === false) {
         return 1;
     }
     $renderer->controller = $this;
     $renderer->render($files, $targetDir);
     $this->stdout('Publishing images...');
     foreach ($sourceDirs as $source) {
         $imageDir = rtrim($source, '/\\') . '/images';
         if (file_exists($imageDir)) {
             FileHelper::copyDirectory($imageDir, $targetDir . '/images');
         }
     }
     $this->stdout('done.' . PHP_EOL, Console::FG_GREEN);
 }
开发者ID:tonylow,项目名称:skillslink,代码行数:56,代码来源:GuideController.php

示例8: initHomeDir

 /**
  * Initialise the home directory:
  * - if not present, create it copying the content from the home-dist directory
  * - if present check if the home directory is up to date with the latest DeploYii version
  */
 public static function initHomeDir()
 {
     if (!self::$_initialised) {
         $home = self::getHomeDir();
         if (!is_dir($home)) {
             FileHelper::copyDirectory(__DIR__ . '/../home-dist', $home);
             @unlink($home . '/README.md');
             VersionManager::updateHomeVersion();
         } else {
             $homeVersion = VersionManager::getHomeVersion();
             VersionManager::checkHomeVersion($homeVersion);
         }
     }
     self::$_initialised = true;
 }
开发者ID:giovdk21,项目名称:deployii,代码行数:20,代码来源:Shell.php

示例9: copy

 /**
  * Copies original module files to destination folder.
  * @return bool
  * @throws ErrorException
  */
 private function copy()
 {
     $source = Yii::getAlias($this->source);
     if (!file_exists($source) || !is_dir($source)) {
         throw new ErrorException("Source directory {$this->source} not found");
     }
     $destination = Yii::getAlias($this->destination);
     if (!$this->replace && is_dir($destination)) {
         // if replace is disabled we will skip existing files
         $this->keepFiles = FileHelper::findFiles($destination);
     }
     FileHelper::copyDirectory($source, $destination, ['except' => ['.git/'], 'fileMode' => 0775, 'beforeCopy' => function ($from, $to) {
         return $this->replace || !file_exists($to) || !is_file($to);
     }]);
     return true;
 }
开发者ID:bariew,项目名称:yii2-tools,代码行数:21,代码来源:CloneController.php

示例10: _copyMigrations

 /**
  * @throws \Exception
  * @throws \yii\base\ErrorException
  * @throws \yii\base\Exception
  */
 protected function _copyMigrations()
 {
     $this->stdout("Copy the migration files in a single directory\n", Console::FG_YELLOW);
     $tmpMigrateDir = \Yii::getAlias($this->_runtimeMigrationPath);
     FileHelper::removeDirectory($tmpMigrateDir);
     FileHelper::createDirectory($tmpMigrateDir);
     if (!is_dir($tmpMigrateDir)) {
         $this->stdout("Could not create a temporary directory migration\n");
         die;
     }
     $this->stdout("\tCreated a directory migration\n");
     if ($dirs = $this->_findMigrationDirs()) {
         foreach ($dirs as $path) {
             FileHelper::copyDirectory($path, $tmpMigrateDir);
         }
     }
     $this->stdout("\tThe copied files modules migrations\n");
     $appMigrateDir = \Yii::getAlias("@console/migrations");
     if (is_dir($appMigrateDir)) {
         FileHelper::copyDirectory($appMigrateDir, $tmpMigrateDir);
     }
     $this->stdout("\tThe copied files app migrations\n\n");
 }
开发者ID:skeeks-cms,项目名称:cms,代码行数:28,代码来源:MigrateController.php

示例11: actionGenerate

 /**
  * Generates the Definitive Guide for the specified version of Yii.
  * @param string $version version number, such as 1.1, 2.0
  * @return integer exit status
  */
 public function actionGenerate($version)
 {
     $versions = Yii::$app->params['guide.versions'];
     if (!isset($versions[$version])) {
         $this->stderr("Unknown version {$version}. Valid versions are " . implode(', ', array_keys($versions)) . "\n\n", Console::FG_RED);
         return 1;
     }
     $languages = $versions[$version];
     $targetPath = Yii::getAlias('@app/data');
     $sourcePath = Yii::getAlias('@app/data');
     try {
         // prepare elasticsearch index
         SearchGuideSection::setMappings();
         sleep(1);
     } catch (\Exception $e) {
         if (YII_DEBUG) {
             $this->stdout("!!! FAILED to prepare elasticsearch index !!! Search will not be available.\n", Console::FG_RED, Console::BOLD);
             $this->stdout((string) $e . "\n\n");
         } else {
             throw $e;
         }
     }
     if ($version[0] === '2') {
         foreach ($languages as $language => $name) {
             $source = "{$sourcePath}/yii-{$version}/docs/guide";
             if ($language !== 'en') {
                 if (strpos($language, '-') !== false) {
                     list($lang, $locale) = explode('-', $language);
                     $source .= "-{$lang}" . (empty($locale) ? '' : '-' . strtoupper($locale));
                 } else {
                     $source .= "-{$language}";
                 }
             }
             $target = "{$targetPath}/guide-{$version}/{$language}";
             $pdfTarget = "{$targetPath}/guide-{$version}/{$language}/pdf";
             $this->version = $version;
             $this->language = $language;
             $this->apiDocs = Yii::getAlias("@app/data/api-{$version}");
             $this->stdout("Start generating guide {$version} in {$name}...\n", Console::FG_CYAN);
             $this->template = 'bootstrap';
             $this->actionIndex([$source], $target);
             $this->generateIndex($source, $target);
             $this->stdout("Finished guide {$version} in {$name}.\n\n", Console::FG_CYAN);
             // set LaTeX language
             $languageMap = Yii::$app->params['guide-pdf.languages'];
             if (isset($languageMap[$language])) {
                 $this->stdout("Start generating guide {$version} PDF in {$name}...\n", Console::FG_CYAN);
                 $this->template = 'pdf';
                 $this->actionIndex([$source], $pdfTarget);
                 $this->stdout('Generating PDF with pdflatex...');
                 file_put_contents("{$pdfTarget}/main.tex", str_replace('british', $languageMap[$language], file_get_contents("{$pdfTarget}/main.tex")));
                 exec('cd ' . escapeshellarg($pdfTarget) . ' && make pdf', $output, $ret);
                 if ($ret === 0) {
                     $this->stdout("\nFinished guide {$version} PDF in {$name}.\n\n", Console::FG_CYAN);
                 } else {
                     $this->stdout("\n" . implode("\n", $output) . "\n");
                     $this->stdout("Guide {$version} PDF failed, make exited with status {$ret}.\n\n", Console::FG_RED);
                 }
             } else {
                 $this->stdout("Guide PDF is not available for {$name}.\n\n", Console::FG_CYAN);
             }
         }
     }
     if ($version[0] === '1') {
         foreach ($languages as $language => $name) {
             $unnormalizedLanguage = strtolower(str_replace('-', '_', $language));
             $source = "{$sourcePath}/yii-{$version}/docs/guide";
             $target = "{$targetPath}/guide-{$version}/{$language}";
             //                $pdfTarget = "$targetPath/guide-$version/$language/pdf"; TODO
             $this->version = $version;
             $this->language = $language;
             FileHelper::createDirectory($target);
             $renderer = new Yii1GuideRenderer(['basePath' => $source, 'targetPath' => $target]);
             $this->stdout("Start generating guide {$version} in {$name}...\n", Console::FG_CYAN);
             $renderer->renderGuide($version, $unnormalizedLanguage);
             $this->generateIndexYii1($source, $target, $version, $unnormalizedLanguage);
             FileHelper::copyDirectory("{$source}/images", "{$target}/images");
             $this->stdout("Finished guide {$version} in {$name}.\n\n", Console::FG_CYAN);
         }
         // generate blog tutorial
         if (isset(Yii::$app->params['blogtut.versions'][$version])) {
             foreach (Yii::$app->params['blogtut.versions'][$version] as $language => $name) {
                 $unnormalizedLanguage = strtolower(str_replace('-', '_', $language));
                 $source = "{$sourcePath}/yii-{$version}/docs/blog";
                 $target = "{$targetPath}/blogtut-{$version}/{$language}";
                 //                $pdfTarget = "$targetPath/guide-$version/$language/pdf"; TODO
                 $this->version = $version;
                 $this->language = $language;
                 FileHelper::createDirectory($target);
                 $renderer = new Yii1GuideRenderer(['basePath' => $source, 'targetPath' => $target]);
                 $this->stdout("Start generating blog tutorial {$version} in {$name}...\n", Console::FG_CYAN);
                 $renderer->renderBlog($version, $unnormalizedLanguage);
                 $this->generateIndexYii1($source, $target, $version, $unnormalizedLanguage, 'blog');
                 FileHelper::copyDirectory("{$source}/images", "{$target}/images");
                 $this->stdout("Finished blog tutorial {$version} in {$name}.\n\n", Console::FG_CYAN);
//.........这里部分代码省略.........
开发者ID:philippfrenzel,项目名称:yiiframework.com,代码行数:101,代码来源:GuideController.php

示例12: actionCopy

 public function actionCopy($id)
 {
     $module = Module::findOne($id);
     $formModel = new CopyModuleForm();
     if ($module === null) {
         $this->flash('error', 'Not found');
         return $this->redirect('/populac/modules');
     }
     if ($formModel->load(Yii::$app->request->post())) {
         if (Yii::$app->request->isAjax) {
             Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
             return ActiveForm::validate($formModel);
         } else {
             $reflector = new \ReflectionClass($module->class);
             $oldModuleFolder = dirname($reflector->getFileName());
             $oldNameSpace = $reflector->getNamespaceName();
             $oldModuleClass = $reflector->getShortName();
             $newModulesFolder = Yii::getAlias('@app') . DIRECTORY_SEPARATOR . 'modules';
             $newModuleFolder = Yii::getAlias('@app') . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . $formModel->name;
             //$newNameSpace = 'app\modules\\'.$formModel->name;
             $newNameSpace = 'backend\\modules\\' . $formModel->name;
             $newModuleClass = ucfirst($formModel->name) . 'Module';
             if (!FileHelper::createDirectory($newModulesFolder, 0755)) {
                 $this->flash('error', 'Cannot create `' . $newModulesFolder . '`. Please check write permissions.');
                 return $this->refresh();
             }
             if (file_exists($newModuleFolder)) {
                 $this->flash('error', 'New module folder `' . $newModulesFolder . '` already exists.');
                 return $this->refresh();
             }
             //Copying module folder
             try {
                 FileHelper::copyDirectory($oldModuleFolder, $newModuleFolder);
             } catch (\Exception $e) {
                 $this->flash('error', 'Cannot copy `' . $oldModuleFolder . '` to `' . $newModuleFolder . '`. Please check write permissions.');
                 return $this->refresh();
             }
             //Renaming module file name
             $newModuleFile = $newModuleFolder . DIRECTORY_SEPARATOR . $newModuleClass . '.php';
             $oldModuleFile = $newModuleFolder . DIRECTORY_SEPARATOR . $reflector->getShortName() . '.php';
             if (!rename($oldModuleFile, $newModuleFile)) {
                 $this->flash('error', 'Cannot rename `' . $newModulesFolder . '`.');
                 return $this->refresh();
             }
             //Renaming module class name
             $moduleFileContent = file_get_contents($newModuleFile);
             $moduleFileContent = str_replace($oldModuleClass, $newModuleClass, $moduleFileContent);
             $moduleFileContent = str_replace('@easyii', '@app', $moduleFileContent);
             $moduleFileContent = str_replace('/' . $module->name, '/' . $formModel->name, $moduleFileContent);
             file_put_contents($newModuleFile, $moduleFileContent);
             //Replacing namespace
             foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($newModuleFolder)) as $file => $object) {
                 if (!$object->isDir()) {
                     $fileContent = file_get_contents($file);
                     $fileContent = str_replace($oldNameSpace, $newNameSpace, $fileContent);
                     $fileContent = str_replace("Yii::t('easyii/" . $module->name, "Yii::t('easyii/" . $formModel->name, $fileContent);
                     $fileContent = str_replace("'" . $module->name . "'", "'" . $formModel->name . "'", $fileContent);
                     file_put_contents($file, $fileContent);
                 }
             }
             //Copying module tables
             foreach (glob($newModuleFolder . DIRECTORY_SEPARATOR . 'models' . DIRECTORY_SEPARATOR . '*.php') as $modelFile) {
                 $baseName = basename($modelFile, '.php');
                 $modelClass = $newNameSpace . '\\models\\' . $baseName;
                 $oldTableName = $modelClass::tableName();
                 $newTableName = str_replace($module->name, $formModel->name, $oldTableName);
                 $newTableName = str_replace('easyii', 'app', $newTableName);
                 //Yii::info($oldTableName, 'oldtb');
                 //Yii::info($newTableName, 'newtb');
                 try {
                     //Drop new table if exists
                     //如果有用到表前缀必须 ".$newTableName." 这样写
                     //如果没有用到表前缀则必须改为 "DROP TABLE IF EXISTS `$newTableName`;" 的写法。
                     Yii::$app->db->createCommand("DROP TABLE IF EXISTS " . $newTableName . ";")->execute();
                     //Copy new table
                     Yii::$app->db->createCommand("CREATE TABLE " . $newTableName . " LIKE " . $oldTableName . ";")->execute();
                 } catch (\yii\db\Exception $e) {
                     $this->flash('error', 'Copy table error. ' . $e);
                     FileHelper::removeDirectory($newModuleFolder);
                     return $this->refresh();
                 }
                 file_put_contents($modelFile, str_replace($oldTableName, $newTableName, file_get_contents($modelFile)));
             }
             $newModule = new Module(['name' => $formModel->name, 'class' => $newNameSpace . '\\' . $newModuleClass, 'title' => $formModel->title, 'icon' => $module->icon, 'settings' => $module->settings, 'status' => Module::STATUS_ON]);
             if ($newModule->save()) {
                 $this->flash('success', 'New module created');
                 return $this->redirect(['/populac/modules/edit', 'id' => $newModule->primaryKey]);
             } else {
                 $this->flash('error', 'Module create error. ' . $newModule->formatErrors());
                 FileHelper::removeDirectory($newModuleFolder);
                 return $this->refresh();
             }
         }
     }
     return $this->render('copy', ['model' => $module, 'formModel' => $formModel]);
 }
开发者ID:tqsq2005,项目名称:Yii2adv,代码行数:96,代码来源:ModulesController.php

示例13: update

 /**
  * 更新插件
  */
 public static function update($pluginid)
 {
     $data = array('status' => self::STATUS_ERROR, 'msg' => '未知错误');
     $updateDir = self::GetPluginPath($pluginid) . "/update/";
     $configRaw = self::GetPluginConfig($pluginid, false, $updateDir);
     $config = $configRaw['config'];
     if ($config) {
         //更新config
         $oldVersionRows = SystemConfig::Get(strtoupper("PLUGIN_{$pluginid}_VERSION"), null, "USER");
         $oldVersionRow = array_shift($oldVersionRows);
         $oldVersion = !empty($oldVersionRow) ? floatval($oldVersionRow['cfg_value']) : 0;
         $newVersion = floatval($config['version']);
         if ($newVersion > $oldVersion) {
             try {
                 //更新配置文件
                 $conffile = $updateDir . "config.php";
                 $destconffile = self::GetPluginPath($pluginid) . "/config.php";
                 if (is_file($conffile)) {
                     copy($conffile, $destconffile);
                 }
                 //更新lib和views
                 $libDir = $updateDir . "lib";
                 $viewsDir = $updateDir . "views";
                 if (is_dir($viewsDir)) {
                     FileHelper::copyDirectory($viewsDir, self::GetPluginPath($pluginid) . "/views");
                 }
                 if (is_dir($libDir)) {
                     FileHelper::copyDirectory($libDir, self::GetPluginPath($pluginid) . "/lib");
                 }
             } catch (ErrorException $e) {
                 return ['status' => self::STATUS_ERROR, 'msg' => "更新失败,没有权限移动升级文件,请修正权限"];
             }
             $data['status'] = self::STATUS_SUCCESS;
             $data['msg'] = "更新完成!";
             if (!$config['onlyupdatefiles']) {
                 //卸载 只删除数据库中菜单的配置
                 self::unsetup($pluginid);
                 //更新配置
                 $_data = self::setup($pluginid);
                 if (!$_data['status']) {
                     $data['msg'] .= ' ' . $_data['msg'];
                 }
             } else {
                 //更新数据库的插件版本号
                 if ($oldVersionRow) {
                     $id = isset($oldVersionRow['id']) ? $oldVersionRow['id'] : 0;
                     if ($id > 0) {
                         $params = $oldVersionRow;
                         $params['cfg_value'] = $newVersion;
                         SystemConfig::Update($id, $params);
                     }
                 }
             }
             //删除升级目录
             FileHelper::removeDirectory($updateDir);
         } else {
             $data['msg'] = '更新失败,版本号低于当前版本,禁止更新操作!';
         }
     } else {
         $data['msg'] = '更新失败,配置文件有误!';
     }
     return $data;
 }
开发者ID:keyeMyria,项目名称:YetCMS,代码行数:66,代码来源:Mplugin.php

示例14: testCopyDirectoryExclude

 /**
  * @see https://github.com/yiisoft/yii2/issues/3393
  *
  * @depends testCopyDirectory
  * @depends testFindFiles
  */
 public function testCopyDirectoryExclude()
 {
     $srcDirName = 'test_src_dir';
     $textFiles = ['file1.txt' => 'text file 1 content', 'file2.txt' => 'text file 2 content'];
     $dataFiles = ['file1.dat' => 'data file 1 content', 'file2.dat' => 'data file 2 content'];
     $this->createFileStructure([$srcDirName => array_merge($textFiles, $dataFiles)]);
     $basePath = $this->testFilePath;
     $srcDirName = $basePath . DIRECTORY_SEPARATOR . $srcDirName;
     $dstDirName = $basePath . DIRECTORY_SEPARATOR . 'test_dst_dir';
     FileHelper::copyDirectory($srcDirName, $dstDirName, ['only' => ['*.dat']]);
     $this->assertFileExists($dstDirName, 'Destination directory does not exist!');
     $copiedFiles = FileHelper::findFiles($dstDirName);
     $this->assertCount(2, $copiedFiles, 'wrong files count copied');
     foreach ($dataFiles as $name => $content) {
         $fileName = $dstDirName . DIRECTORY_SEPARATOR . $name;
         $this->assertFileExists($fileName);
         $this->assertEquals($content, file_get_contents($fileName), 'Incorrect file content!');
     }
 }
开发者ID:howq,项目名称:yii2,代码行数:25,代码来源:FileHelperTest.php

示例15: testCopyDirectoryPermissions

 /**
  * @depends testCopyDirectory
  */
 public function testCopyDirectoryPermissions()
 {
     if (substr(PHP_OS, 0, 3) == 'WIN') {
         $this->markTestSkipped("Can't reliably test it on Windows because fileperms() always return 0777.");
     }
     $srcDirName = 'test_src_dir';
     $subDirName = 'test_sub_dir';
     $fileName = 'test_file.txt';
     $this->createFileStructure([$srcDirName => [$subDirName => [], $fileName => 'test file content']]);
     $basePath = $this->testFilePath;
     $srcDirName = $basePath . DIRECTORY_SEPARATOR . $srcDirName;
     $dstDirName = $basePath . DIRECTORY_SEPARATOR . 'test_dst_dir';
     $dirMode = 0755;
     $fileMode = 0755;
     $options = ['dirMode' => $dirMode, 'fileMode' => $fileMode];
     FileHelper::copyDirectory($srcDirName, $dstDirName, $options);
     $this->assertFileMode($dirMode, $dstDirName, 'Destination directory has wrong mode!');
     $this->assertFileMode($dirMode, $dstDirName . DIRECTORY_SEPARATOR . $subDirName, 'Copied sub directory has wrong mode!');
     $this->assertFileMode($fileMode, $dstDirName . DIRECTORY_SEPARATOR . $fileName, 'Copied file has wrong mode!');
 }
开发者ID:rajanishtimes,项目名称:basicyii,代码行数:23,代码来源:FileHelperTest.php


注:本文中的yii\helpers\FileHelper::copyDirectory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。