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


PHP Terminus::getConfig方法代码示例

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


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

示例1: testGetConfig

 public function testGetConfig()
 {
     $format = Terminus::getConfig('format');
     $this->assertEquals($format, 'normal');
     $config = Terminus::getConfig();
     $this->assertInternalType('array', $config);
 }
开发者ID:barkinet,项目名称:cli,代码行数:7,代码来源:test-terminus.php

示例2: testGetConfig

 /**
  * @expectedException \Terminus\Exceptions\TerminusException
  * @expectedExceptionMessage Unknown config option "{key}".
  */
 public function testGetConfig()
 {
     $format = Terminus::getConfig('format');
     $this->assertTrue(in_array($format, ['normal', 'json', 'silent', 'bash']));
     $config = Terminus::getConfig();
     $this->assertInternalType('array', $config);
     $invalid = Terminus::getConfig('invalid');
 }
开发者ID:karudonaldson,项目名称:terminus,代码行数:12,代码来源:test-terminus.php

示例3: __invoke

 /**
  * Invoke `drush` commands on a Pantheon development site
  *
  * <commands>...
  * : The Drush commands you intend to run.
  *
  * [--<flag>=<value>]
  * : Additional Drush flag(s) to pass in to the command.
  *
  * [--site=<site>]
  * : The name (DNS shortname) of your site on Pantheon.
  *
  * [--env=<environment>]
  * : Your Pantheon environment. Default: dev
  *
  */
 public function __invoke($args, $assoc_args)
 {
     $command = implode($args, ' ');
     $this->checkCommand($command);
     $sites = new Sites();
     $assoc_args['site'] = Input::sitename($assoc_args);
     $site = $sites->get($assoc_args['site']);
     if (!$site) {
         $this->failure('Command could not be completed. Unknown site specified.');
     }
     $assoc_args['env'] = $environment = Input::env($assoc_args);
     $server = $this->getAppserverInfo(array('site' => $site->get('id'), 'environment' => $environment));
     # Sanitize assoc args so we don't try to pass our own flags.
     # TODO: DRY this out?
     if (isset($assoc_args['site'])) {
         unset($assoc_args['site']);
     }
     if (isset($assoc_args['env'])) {
         unset($assoc_args['env']);
     }
     # Create user-friendly output
     $flags = '';
     foreach ($assoc_args as $k => $v) {
         if (isset($v) && (string) $v != '') {
             $flags .= "--{$k}={$v} ";
         } else {
             $flags .= "--{$k} ";
         }
     }
     if (in_array(Terminus::getConfig('format'), array('bash', 'json', 'silent'))) {
         $assoc_args['pipe'] = 1;
     }
     $this->log()->info("Running drush {cmd} {flags} on {site}-{env}", array('cmd' => $command, 'flags' => $flags, 'site' => $site->get('name'), 'env' => $environment));
     $result = $this->sendCommand($server, 'drush', $args, $assoc_args);
     if (Terminus::getConfig('format') != 'normal') {
         $this->output()->outputRecordList($result);
     }
 }
开发者ID:RobLoach,项目名称:cli,代码行数:54,代码来源:drush.php

示例4: __invoke

 /**
  * Invoke `drush` commands on a Pantheon development site
  *
  * <commands>...
  * : The Drush commands you intend to run.
  *
  * [--<flag>=<value>]
  * : Additional Drush flag(s) to pass in to the command.
  *
  * [--site=<site>]
  * : The name (DNS shortname) of your site on Pantheon.
  *
  * [--env=<environment>]
  * : Your Pantheon environment. Default: dev
  *
  */
 function __invoke($args, $assoc_args)
 {
     $environment = Input::env($assoc_args);
     $sites = new Sites();
     $site = $sites->get(Input::sitename($assoc_args));
     if (!$site) {
         $this->failure('Command could not be completed. Unknown site specified.');
     }
     $server = array('user' => "{$environment}.{$site->get('id')}", 'host' => "appserver.{$environment}.{$site->get('id')}.drush.in", 'port' => '2222');
     if (strpos(TERMINUS_HOST, 'onebox') !== FALSE) {
         $server['user'] = "appserver.{$environment}.{$site->get('id')}";
         $server['host'] = TERMINUS_HOST;
     }
     # Sanitize assoc args so we don't try to pass our own flags.
     # TODO: DRY this out?
     unset($assoc_args['site']);
     if (isset($assoc_args['env'])) {
         unset($assoc_args['env']);
     }
     # Create user-friendly output
     $command = implode($args, ' ');
     $flags = '';
     foreach ($assoc_args as $k => $v) {
         if (isset($v) && (string) $v != '') {
             $flags .= "--{$k}={$v} ";
         } else {
             $flags .= "--{$k} ";
         }
     }
     if (in_array(\Terminus::getConfig('format'), array('bash', 'json', 'silent'))) {
         $assoc_args['pipe'] = 1;
     }
     $this->log()->info("Running drush {cmd} {flags} on {site}-{env}", array('cmd' => $command, 'flags' => $flags, 'site' => $site->get('name'), 'env' => $environment));
     $result = $this->sendCommand($server, 'drush', $args, $assoc_args);
     if (Terminus::getConfig('format') != 'normal') {
         $this->output()->outputRecordList($result);
     }
 }
开发者ID:andrefy,项目名称:cli,代码行数:54,代码来源:drush.php

示例5: __invoke

 /**
  * Invoke `wp` commands on a Pantheon development site
  *
  * <commands>...
  * : The WP-CLI commands you intend to run.
  *
  * [--<flag>=<value>]
  * : Additional WP-CLI flag(s) to pass in to the command.
  *
  * [--site=<site>]
  * : The name (DNS shortname) of your site on Pantheon.
  *
  * [--env=<environment>]
  * : Your Pantheon environment. Default: dev
  *
  */
 function __invoke($args, $assoc_args)
 {
     $command = implode($args, ' ');
     $this->checkCommand($command);
     $sites = new Sites();
     $site = $sites->get(Input::sitename($assoc_args));
     $environment = Input::env($assoc_args);
     if (!$site) {
         $this->failure('Command could not be completed. Unknown site specified.');
     }
     # see https://github.com/pantheon-systems/titan-mt/blob/master/dashboardng/app/workshops/site/models/environment.coffee
     $server = array('user' => "{$environment}.{$site->get('id')}", 'host' => "appserver.{$environment}.{$site->get('id')}.drush.in", 'port' => '2222');
     if (strpos(TERMINUS_HOST, 'onebox') !== FALSE) {
         $server['user'] = "appserver.{$environment}.{$site->get('id')}";
         $server['host'] = TERMINUS_HOST;
     }
     # Sanitize assoc args so we don't try to pass our own flags.
     # TODO: DRY this out?
     unset($assoc_args['site']);
     if (isset($assoc_args['env'])) {
         unset($assoc_args['env']);
     }
     # Create user-friendly output
     $flags = '';
     foreach ($assoc_args as $k => $v) {
         if (isset($v) && (string) $v != '') {
             $flags .= "--{$k}=" . escapeshellarg($v) . ' ';
         } else {
             $flags .= "--{$k} ";
         }
     }
     $this->log()->info("Running wp {cmd} {flags} on {site}-{env}", array('cmd' => $command, 'flags' => $flags, 'site' => $site->get('name'), 'env' => $environment));
     $result = $this->sendCommand($server, 'wp', $args, $assoc_args);
     if (Terminus::getConfig('format') != 'normal') {
         $this->output()->outputRecordList($result);
     }
 }
开发者ID:RobLoach,项目名称:cli,代码行数:53,代码来源:wp.php

示例6: hostnames

 /**
  * Hostname operations
  *
  * ## OPTIONS
  *
  * <list|add|remove>
  * : OPTIONS are list, add, delete
  *
  * [--site=<site>]
  * : Site to use
  *
  * --env=<env>
  * : environment to use
  *
  * [--hostname=<hostname>]
  * : hostname to add
  *
  */
 public function hostnames($args, $assoc_args)
 {
     $action = array_shift($args);
     $site = $this->sites->get(Input::sitename($assoc_args));
     $env = $site->environments->get(Input::env($assoc_args, 'env'));
     switch ($action) {
         case 'list':
             $hostnames = $env->getHostnames();
             $data = $hostnames;
             if (Terminus::getConfig('format') != 'json') {
                 //If were not just dumping the JSON, then we should reformat the data.
                 $data = array();
                 foreach ($hostnames as $hostname => $details) {
                     $data[] = array_merge(array('domain' => $hostname), (array) $details);
                 }
             }
             $this->output()->outputRecordList($data);
             break;
         case 'add':
             if (!isset($assoc_args['hostname'])) {
                 $this->failure('Must specify hostname with --hostname');
             }
             $data = $env->addHostname($assoc_args['hostname']);
             $this->log()->debug(json_encode($data));
             $this->log()->info('Added {hostname} to {site}-{env}', array('hostname' => $assoc_args['hostname'], 'site' => $site->get('name'), 'env' => $env->get('id')));
             break;
         case 'remove':
             if (!isset($assoc_args['hostname'])) {
                 $this->failure('Must specify hostname with --hostname');
             }
             $data = $env->deleteHostname($assoc_args['hostname']);
             $this->log()->info('Deleted {hostname} from {site}-{env}', array('hostname' => $assoc_args['hostname'], 'site' => $site->get('name'), 'env' => $env->get('id')));
             break;
     }
     return $data;
 }
开发者ID:RobLoach,项目名称:cli,代码行数:54,代码来源:site.php

示例7: render_subcommands

 private static function render_subcommands($command)
 {
     $subcommands = array();
     foreach ($command->getSubcommands() as $subcommand) {
         $subcommands[$subcommand->getName()] = $subcommand->getShortdesc();
     }
     if (Terminus::getConfig('format') == 'json') {
         return $subcommands;
     }
     $max_len = self::get_max_len(array_keys($subcommands));
     $lines = array();
     foreach ($subcommands as $name => $desc) {
         $lines[] = str_pad($name, $max_len) . "\t\t\t" . $desc;
     }
     return $lines;
 }
开发者ID:RobLoach,项目名称:cli,代码行数:16,代码来源:help.php

示例8: request

 /**
  * Make a request to the Pantheon API
  *
  * @param [string] $realm   Permissions realm for data request (e.g. user,
  *   site organization, etc. Can also be "public" to simply pull read-only
  *   data that is not privileged.
  * @param [string] $uuid    The UUID of the item in the realm to access
  * @param [string] $path    API path (URL)
  * @param [string] $method  HTTP method to use
  * @param [mixed]  $options A native PHP data structure (e.g. int, string,
  *   array, or stdClass) to be sent along with the request
  * @return [array] $data
  */
 public static function request($realm, $uuid, $path = false, $method = 'GET', $options = null)
 {
     if (!in_array($realm, array('login', 'user', 'public'))) {
         Auth::loggedIn();
     }
     try {
         $cache = Terminus::getCache();
         if (!in_array($realm, array('login', 'user'))) {
             $options['cookies'] = array('X-Pantheon-Session' => Session::getValue('session'));
             $options['verify'] = false;
         }
         $url = Endpoint::get(array('realm' => $realm, 'uuid' => $uuid, 'path' => $path));
         if (Terminus::getConfig('debug')) {
             Terminus::log('debug', 'Request URL: ' . $url);
         }
         $resp = Request::send($url, $method, $options);
         $json = $resp->getBody(true);
         $data = array('info' => $resp->getInfo(), 'headers' => $resp->getRawHeaders(), 'json' => $json, 'data' => json_decode($json), 'status_code' => $resp->getStatusCode());
         return $data;
     } catch (Guzzle\Http\Exception\BadResponseException $e) {
         $response = $e->getResponse();
         throw new TerminusException($response->getBody(true));
     } catch (Guzzle\Http\Exception\HttpException $e) {
         $request = $e->getRequest();
         $sanitized_request = TerminusCommand::stripSensitiveData((string) $request, TerminusCommand::$blacklist);
         throw new TerminusException('API Request Error. {msg} - Request: {req}', array('req' => $sanitized_request, 'msg' => $e->getMessage()));
     } catch (Exception $e) {
         throw new TerminusException('API Request Error: {msg}', array('msg' => $e->getMessage()));
     }
 }
开发者ID:andrefy,项目名称:cli,代码行数:43,代码来源:class-terminus-command.php


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