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


PHP PluginManager::onSetup方法代码示例

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


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

示例1: main

 /**
  * The main entry point to the application. Start here!
  * When this returns, the program is done.
  * 
  * Program flow:
  * * Parse options
  * * Set up logging, if requested
  * * Ask plugins to do any early setup - this is where Last.fm / Twitter do OAuth etc
  * * If no filename was supplied, either wait for a new one to be created in the default 
  *   ScratchLive history folder (polls every 2 seconds), or go for the most recent 
  *   (when --immediate is specified). 
  * * If --dump was specified, display the structure of the file and exit. (Very useful for
  *   probing ScratchLive files).
  * * Otherwise, start monitoring the file.
  * 
  * @param $argc (from GLOBAL)
  * @param $argv (from GLOBAL)
  */
 public function main($argc, array $argv)
 {
     date_default_timezone_set('UTC');
     mb_internal_encoding('UTF-8');
     try {
         $this->parseOptions($argv);
         // do this as early as possible, but not before parsing options which may affect it.
         $this->setupLogging();
         if ($this->help) {
             $this->usage($this->appname, $argv);
             return;
         }
         // yield CLI configured plugins.
         foreach ($this->cli_plugins as $plugin) {
             /* @var $plugin CLIPlugin */
             $plugin->addPluginsTo($this->plugin_manager);
         }
         $this->cli_plugins = array();
         $this->plugin_manager->onSetup();
         $filename = $this->filename;
         if (empty($filename)) {
             // guess history file (always go for the most recently modified)
             $this->historydir = $this->getDefaultHistoryDir();
             if ($this->wait_for_file) {
                 echo "Waiting for new session file...\n";
                 // find the most recent file, then wait for a new one to be created and use that.
                 $first_filename = $this->getMostRecentFile($this->historydir, 'session');
                 $second_filename = $first_filename;
                 while ($second_filename == $first_filename) {
                     sleep($this->sleep);
                     $second_filename = $this->getMostRecentFile($this->historydir, 'session');
                 }
                 $filename = $second_filename;
             } else {
                 $filename = $this->getMostRecentFile($this->historydir, 'session');
             }
             echo "Using file {$filename} ...\n";
         }
         if (!file_exists($filename)) {
             throw new InvalidArgumentException("No such file {$filename}.");
         }
         if (!is_readable($filename)) {
             throw new InvalidArgumentException("File {$filename} not readable.");
         }
         if ($this->dump_and_exit) {
             $monitor = new DiffMonitor();
             switch ($this->dump_type) {
                 case 'sessionfile':
                     $hfm = new SSLHistoryFileMonitor($filename, $monitor);
                     break;
                 case 'sessionindex':
                     $hfm = new SSLHistoryIndexFileMonitor($filename, $monitor);
                     break;
                 case 'library':
                     $hfm = new SSLLibraryFileMonitor($filename, $monitor);
                     break;
                 default:
                     throw new RuntimeException('Unknown dump type. Try sessionfile, sessionindex, library');
             }
             $monitor->dump();
             return;
         }
         if ($this->post_process) {
             $this->post_process($filename);
         } else {
             // start monitoring.
             $this->monitor($filename);
         }
     } catch (Exception $e) {
         echo $e->getMessage() . "\n";
         if ($this->verbosity > L::INFO) {
             echo $e->getTraceAsString() . "\n";
         }
         echo "Try {$this->appname} --help\n";
     }
 }
开发者ID:rabyunghwa,项目名称:sslscrobbler,代码行数:94,代码来源:HistoryReader.php


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