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


PHP Framework::moduleList方法代码示例

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


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

示例1: modules

 /**
  * Various module interactions
  * 	
  * Actions:
  *  list - Lists installed modules
  *  list-remote - Lists available modules
  *    --server=nthalk.com
  *  install - installs a remote package
  *    --dir=app/modules
  *    --server=nthalk.com
  *    --as-git-submodule
  *    --as-git-repo
  *	uninstall - removes a module
  */
 public function modules($like = array(), $options = array())
 {
     $action = array_shift($like);
     if (isset($options['server'])) {
         $server = $options['server'];
     } else {
         $server = 'nthalk.com';
     }
     if ($action == 'uninstall') {
         $module = array_shift($like);
         $module_dir = Framework::moduleInstalled($module);
         if (!$module_dir) {
             $this->write("Module does not appear to be installed: {$module}\n");
             return;
         }
         $this->write("Uninstalling: {$module}\n");
         $this->write("Running uninstall scripts...\n");
         if (method_exists($module, 'uninstall')) {
             if (!call_user_func(array($module, 'uninstall')) || isset($options['force'])) {
                 $this->write("Uninstaller failed... Please inspect {$module}::uninstall() before completely removing or supply --force\n");
                 return;
             }
         }
         $this->write("Removing submodule from app/.git cache...\n");
         $cmd = 'git rm --cached ' . $module_dir;
         //$this->write($cmd . "\n");
         $cmd_p = popen($cmd, 'r');
         $this->write(fread($cmd_p, 10000) . "\n");
         $dir = SERVER_APP_DIR;
         $git_submodules_file = $dir . '/.gitmodules';
         if (file_exists($git_submodules_file)) {
             $git_submodules = file_get_contents($git_submodules_file);
             $match = "/\\[submodule.*{$module}\"\\]\\s+path.*\\s+url.*\\s?/";
             if (preg_match($match, $git_submodules)) {
                 $git_submodules_new = preg_replace($match, '', $git_submodules);
                 $git_submodules_new = preg_replace("/\n+/", "\n", $git_submodules_new);
                 $this->write("Removing submodule from submodules...\n");
                 //$this->write($git_submodules_new . "\n");
                 file_put_contents($git_submodules_file, $git_submodules_new);
             }
         }
         $git_conf_file = $dir . '/.git/config';
         if (file_exists($git_conf_file)) {
             $git_conf = file_get_contents($git_conf_file);
             $match = "/\\[submodule.*{$module}\"\\](\\s+path.*|\\s+url.*)+?\\s?/";
             if (preg_match($match, $git_conf)) {
                 $git_conf_new = preg_replace($match, '', $git_conf);
                 $git_conf_new = preg_replace("/\n+/", "\n", $git_conf_new);
                 $this->write("Removing submodule from config...\n");
                 //$this->write($git_conf_new . "\n");
                 file_put_contents($git_conf_file, $git_conf_new);
             }
         }
         $this->write("Removing submodule from file system...\n");
         $cmd = 'rm -rf ' . $module_dir;
         //$this->write($cmd . "\n");
         $cmd_p = popen($cmd, 'r');
         $this->write(fread($cmd_p, 10000) . "\n");
         $this->write("Done. It is up to you to commit this change into your app repo...\n");
     } else {
         if ($action == 'list') {
             $this->write("Currently installed modules:\n\n");
             foreach (Framework::moduleList(array_shift($like)) as $module) {
                 $this->write(' ' . $module . ' -' . $this->getDocumentation(new ReflectionClass($module)));
             }
             $this->write("\n");
         } else {
             if ($action == 'list-remote') {
                 $content = file_get_contents("http://{$server}/Packages");
                 $packages = json_decode($content);
                 if (!is_array($packages)) {
                     $this->write('Error retrieving data from module server: ' . $server . "\n");
                 } else {
                     foreach ($packages as $package) {
                         $this->write($package->name . " - " . $package->version . "\n");
                     }
                 }
             } else {
                 if ($action == 'install') {
                     if (realpath(getcwd()) !== SERVER_APP_DIR) {
                         $this->write("fatal: You must install modules from the root of your app dir ( " . SERVER_APP_DIR . " )\n");
                         return;
                     }
                     $content = file_get_contents("http://{$server}/Packages");
                     $packages = json_decode($content);
                     if (!is_array($packages)) {
//.........这里部分代码省略.........
开发者ID:MrYogi,项目名称:hasoffers-promotional-platform,代码行数:101,代码来源:Nth.php


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