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


PHP WP_CLI::get_configurator方法代码示例

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


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

示例1: get_lint_config

 /**
  * Get config value from lint config.
  *
  * @param string $key
  *
  * @return mixed
  */
 private function get_lint_config($key)
 {
     $config = WP_CLI::get_configurator()->to_array();
     if (count($config) === 1 || !isset($config[1]['lint'])) {
         return;
     }
     if (!isset($config[1]['lint'][$key])) {
         return;
     }
     return $config[1]['lint'][$key];
 }
开发者ID:frozzare,项目名称:wp-cli-lint,代码行数:18,代码来源:class-lint-command.php

示例2: get_config_value

 /**
  * Get config value from download attachments config.
  *
  * @param  string $key
  *
  * @return mixed
  */
 private function get_config_value($key)
 {
     $config = WP_CLI::get_configurator()->to_array();
     if (count($config) === 1 || !isset($config[1]['media'])) {
         return;
     }
     if (!isset($config[1]['media']['restore']) || !isset($config[1]['media']['restore'][$key])) {
         return;
     }
     return $config[1]['media']['restore'][$key];
 }
开发者ID:frozzare,项目名称:wp-cli-media-restore,代码行数:18,代码来源:class-media-restore-command.php

示例3: get_longdesc

 function get_longdesc()
 {
     $binding = array();
     foreach (\WP_CLI::get_configurator()->get_spec() as $key => $details) {
         if (false === $details['runtime']) {
             continue;
         }
         if (isset($details['deprecated'])) {
             continue;
         }
         if (true === $details['runtime']) {
             $synopsis = "--[no-]{$key}";
         } else {
             $synopsis = "--{$key}" . $details['runtime'];
         }
         $binding['parameters'][] = array('synopsis' => $synopsis, 'desc' => $details['desc']);
     }
     return Utils\mustache_render('man-params.mustache', $binding);
 }
开发者ID:nb,项目名称:wp-cli,代码行数:19,代码来源:RootCommand.php

示例4: init_config

 private function init_config()
 {
     $configurator = \WP_CLI::get_configurator();
     $this->global_config_path = self::get_global_config_path();
     $this->project_config_path = self::get_project_config_path();
     $configurator->merge_yml($this->global_config_path);
     $configurator->merge_yml($this->project_config_path);
     list($args, $assoc_args, $runtime_config) = $configurator->parse_args(array_slice($GLOBALS['argv'], 1));
     list($this->arguments, $this->assoc_args) = self::back_compat_conversions($args, $assoc_args);
     $configurator->merge_array($runtime_config);
     list($this->config, $this->extra_config) = $configurator->to_array();
 }
开发者ID:Jazz-Man,项目名称:wp-cli,代码行数:12,代码来源:Runner.php

示例5: __construct

 function __construct($line)
 {
     // TODO: properly parse single and double quotes
     $this->words = explode(' ', $line);
     // first word is always `wp`
     array_shift($this->words);
     // last word is either empty or an incomplete subcommand
     $this->cur_word = end($this->words);
     if ("" !== $this->cur_word && !preg_match("/^\\-/", $this->cur_word)) {
         array_pop($this->words);
     }
     $is_alias = false;
     $is_help = false;
     if (!empty($this->words[0]) && preg_match("/^@/", $this->words[0])) {
         array_shift($this->words);
         // `wp @al` is false, but `wp @all ` is true.
         if (count($this->words)) {
             $is_alias = true;
         }
     } elseif (!empty($this->words[0]) && 'help' === $this->words[0]) {
         array_shift($this->words);
         $is_help = true;
     }
     $r = $this->get_command($this->words);
     if (!is_array($r)) {
         return;
     }
     list($command, $args, $assoc_args) = $r;
     $spec = SynopsisParser::parse($command->get_synopsis());
     foreach ($spec as $arg) {
         if ($arg['type'] == 'positional' && $arg['name'] == 'file') {
             $this->add('<file> ');
             return;
         }
     }
     if ($command->can_have_subcommands()) {
         // add completion when command is `wp` and alias isn't set.
         if ("wp" === $command->get_name() && false === $is_alias && false == $is_help) {
             $aliases = \WP_CLI::get_configurator()->get_aliases();
             foreach ($aliases as $name => $_) {
                 $this->add("{$name} ");
             }
         }
         foreach ($command->get_subcommands() as $name => $_) {
             $this->add("{$name} ");
         }
     } else {
         foreach ($spec as $arg) {
             if (in_array($arg['type'], array('flag', 'assoc'))) {
                 if (isset($assoc_args[$arg['name']])) {
                     continue;
                 }
                 $opt = "--{$arg['name']}";
                 if ($arg['type'] == 'flag') {
                     $opt .= ' ';
                 } elseif (!$arg['value']['optional']) {
                     $opt .= '=';
                 }
                 $this->add($opt);
             }
         }
     }
 }
开发者ID:wp-cli,项目名称:wp-cli,代码行数:63,代码来源:Completions.php

示例6: init_config

 private function init_config()
 {
     $configurator = \WP_CLI::get_configurator();
     $argv = array_slice($GLOBALS['argv'], 1);
     if (!empty($argv[0]) && preg_match('#^@[A-Za-z0-9-_]+$#', $argv[0], $matches)) {
         $this->alias = array_shift($argv);
     } else {
         $this->alias = null;
     }
     $this->global_config_path = $this->get_global_config_path();
     $this->project_config_path = $this->get_project_config_path();
     $configurator->merge_yml($this->global_config_path);
     $config = $configurator->to_array();
     $this->_required_files['global'] = $config[0]['require'];
     $configurator->merge_yml($this->project_config_path);
     $config = $configurator->to_array();
     $this->_required_files['project'] = $config[0]['require'];
     list($args, $assoc_args, $runtime_config) = $configurator->parse_args($argv);
     list($this->arguments, $this->assoc_args) = self::back_compat_conversions($args, $assoc_args);
     $configurator->merge_array($runtime_config);
     list($this->config, $this->extra_config) = $configurator->to_array();
     $this->aliases = $configurator->get_aliases();
     $this->_required_files['runtime'] = $this->config['require'];
 }
开发者ID:voldemortensen,项目名称:wp-cli,代码行数:24,代码来源:Runner.php

示例7: param_dump

 /**
  * Dump the list of global parameters, as JSON or in var_export format.
  *
  * ## OPTIONS
  *
  * [--with-values]
  * : Display current values also.
  *
  * [--format=<format>]
  * : Accepted values: var_export, json. Default: json.
  *
  * @subcommand param-dump
  */
 function param_dump($_, $assoc_args)
 {
     $spec = \WP_CLI::get_configurator()->get_spec();
     if (\WP_CLI\Utils\get_flag_value($assoc_args, 'with-values')) {
         $config = \WP_CLI::get_configurator()->to_array();
         // Copy current config values to $spec
         foreach ($spec as $key => $value) {
             if (isset($config[0][$key])) {
                 $current = $config[0][$key];
             } else {
                 $current = NULL;
             }
             $spec[$key]['current'] = $current;
         }
     }
     if ('var_export' === \WP_CLI\Utils\get_flag_value($assoc_args, 'format')) {
         var_export($spec);
     } else {
         echo json_encode($spec);
     }
 }
开发者ID:supersighs,项目名称:wp-cli,代码行数:34,代码来源:cli.php

示例8: get_global_params

 protected function get_global_params($root_command = false)
 {
     $binding = array();
     $binding['root_command'] = $root_command;
     if (!$this->can_have_subcommands() || is_object($this->parent) && get_class($this->parent) == 'WP_CLI\\Dispatcher\\CompositeCommand') {
         $binding['is_subcommand'] = true;
     }
     foreach (\WP_CLI::get_configurator()->get_spec() as $key => $details) {
         if (false === $details['runtime']) {
             continue;
         }
         if (isset($details['deprecated'])) {
             continue;
         }
         if (isset($details['hidden'])) {
             continue;
         }
         if (true === $details['runtime']) {
             $synopsis = "--[no-]{$key}";
         } else {
             $synopsis = "--{$key}" . $details['runtime'];
         }
         $binding['parameters'][] = array('synopsis' => $synopsis, 'desc' => $details['desc']);
     }
     if ($this->get_subcommands()) {
         $binding['has_subcommands'] = true;
     }
     return Utils\mustache_render('man-params.mustache', $binding);
 }
开发者ID:wesm87,项目名称:wp-cli,代码行数:29,代码来源:CompositeCommand.php

示例9: param_dump

 /**
  * Dump the list of global parameters, as JSON.
  *
  * @subcommand param-dump
  */
 function param_dump()
 {
     echo json_encode(\WP_CLI::get_configurator()->get_spec());
 }
开发者ID:nb,项目名称:wp-cli,代码行数:9,代码来源:cli.php

示例10: runcommand

 /**
  * Run a WP-CLI command.
  *
  * Launch a new child process, or run the command in the current process.
  * Optionally:
  * * Prevent halting script execution on error.
  * * Capture and return STDOUT, or full details about command execution.
  * * Parse JSON output if the command rendered it.
  *
  * ```
  * $options = array(
  *   'return'     => true,   // Return 'STDOUT'; use 'all' for full object.
  *   'parse'      => 'json', // Parse captured STDOUT to JSON array.
  *   'launch'     => false,  // Reuse the current process.
  *   'exit_error' => true,   // Halt script execution on error.
  * );
  * $plugins = WP_CLI::runcommand( 'plugin list --format=json', $options );
  * ```
  *
  * @access public
  * @category Execution
  *
  * @param string $command WP-CLI command to run, including arguments.
  * @param array  $options Configuration options for command execution.
  * @return mixed
  */
 public static function runcommand($command, $options = array())
 {
     $defaults = array('launch' => true, 'exit_error' => true, 'return' => false, 'parse' => false);
     $options = array_merge($defaults, $options);
     $launch = $options['launch'];
     $exit_error = $options['exit_error'];
     $return = $options['return'];
     $parse = $options['parse'];
     $retval = null;
     if ($launch) {
         if ($return) {
             $descriptors = array(0 => STDIN, 1 => array('pipe', 'w'), 2 => array('pipe', 'w'));
         } else {
             $descriptors = array(0 => STDIN, 1 => STDOUT, 2 => STDERR);
         }
         $php_bin = self::get_php_binary();
         $script_path = $GLOBALS['argv'][0];
         // Persist runtime arguments unless they've been specified otherwise.
         $configurator = \WP_CLI::get_configurator();
         $argv = array_slice($GLOBALS['argv'], 1);
         list($_, $_, $runtime_config) = $configurator->parse_args($argv);
         foreach ($runtime_config as $k => $v) {
             if (preg_match("|^--{$key}=?\$|", $command)) {
                 unset($runtime_config[$k]);
             }
         }
         $runtime_config = Utils\assoc_args_to_str($runtime_config);
         $runcommand = "{$php_bin} {$script_path} {$runtime_config} {$command}";
         $env_vars = array('HOME', 'WP_CLI_AUTO_CHECK_UPDATE_DAYS', 'WP_CLI_CACHE_DIR', 'WP_CLI_CONFIG_PATH', 'WP_CLI_DISABLE_AUTO_CHECK_UPDATE', 'WP_CLI_PACKAGES_DIR', 'WP_CLI_PHP_USED', 'WP_CLI_PHP', 'WP_CLI_STRICT_ARGS_MODE');
         $env = array();
         foreach ($env_vars as $var) {
             $env[$var] = getenv($var);
         }
         $proc = proc_open($runcommand, $descriptors, $pipes, getcwd(), $env);
         if ($return) {
             $stdout = stream_get_contents($pipes[1]);
             fclose($pipes[1]);
             $stderr = stream_get_contents($pipes[2]);
             fclose($pipes[2]);
         }
         $return_code = proc_close($proc);
         if (-1 == $return_code) {
             self::warning("Spawned process returned exit code -1, which could be caused by a custom compiled version of PHP that uses the --enable-sigchild option.");
         } else {
             if ($return_code && $exit_error) {
                 exit($return_code);
             }
         }
         if (true === $return || 'stdout' === $return) {
             $retval = trim($stdout);
         } else {
             if ('stderr' === $return) {
                 $retval = trim($stderr);
             } else {
                 if ('return_code' === $return) {
                     $retval = $return_code;
                 } else {
                     if ('all' === $return) {
                         $retval = (object) array('stdout' => trim($stdout), 'stderr' => trim($stderr), 'return_code' => $return_code);
                     }
                 }
             }
         }
     } else {
         $configurator = self::get_configurator();
         $argv = Utils\parse_str_to_argv($command);
         list($args, $assoc_args, $runtime_config) = $configurator->parse_args($argv);
         if ($return) {
             ob_start();
             $existing_logger = self::$logger;
             self::$logger = new WP_CLI\Loggers\Execution();
         }
         if (!$exit_error) {
             self::$capture_exit = true;
//.........这里部分代码省略.........
开发者ID:wp-cli,项目名称:wp-cli,代码行数:101,代码来源:class-wp-cli.php

示例11: init_config

 private function init_config()
 {
     $configurator = \WP_CLI::get_configurator();
     $argv = array_slice($GLOBALS['argv'], 1);
     if (!empty($argv[0]) && preg_match('#' . Configurator::ALIAS_REGEX . '#', $argv[0], $matches)) {
         $this->alias = array_shift($argv);
     } else {
         $this->alias = null;
     }
     $this->global_config_path = $this->get_global_config_path();
     $this->project_config_path = $this->get_project_config_path();
     $configurator->merge_yml($this->global_config_path, $this->alias);
     $config = $configurator->to_array();
     $this->_required_files['global'] = $config[0]['require'];
     $configurator->merge_yml($this->project_config_path, $this->alias);
     $config = $configurator->to_array();
     $this->_required_files['project'] = $config[0]['require'];
     list($args, $assoc_args, $runtime_config) = $configurator->parse_args($argv);
     list($this->arguments, $this->assoc_args) = self::back_compat_conversions($args, $assoc_args);
     $configurator->merge_array($runtime_config);
     list($this->config, $this->extra_config) = $configurator->to_array();
     $this->aliases = $configurator->get_aliases();
     if (count($this->aliases) && !isset($this->aliases['@all'])) {
         $this->aliases = array_reverse($this->aliases);
         $this->aliases['@all'] = 'Run command against every registered alias.';
         $this->aliases = array_reverse($this->aliases);
     }
     $this->_required_files['runtime'] = $this->config['require'];
 }
开发者ID:wp-cli,项目名称:wp-cli,代码行数:29,代码来源:Runner.php


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