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


PHP Terminus::log方法代码示例

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


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

示例1: index

 /**
  * Show all sites user has access to
  * Note: because of the size of this call, it is cached
  *   and also is the basis for loading individual sites by name
  *
  * [--team]
  * : filter sites you are a team member of
  *
  * [--org=<id>]
  * : filter sites you can access via the organization
  *
  * @subcommand list
  * @alias show
  */
 public function index($args, $assoc_args)
 {
     // Always fetch a fresh list of sites
     $this->sitesCache->rebuild();
     $cached_sites = $this->sitesCache->all();
     $rows = array_map(function ($cached_site) {
         return array('name' => $cached_site['name'], 'id' => $cached_site['id'], 'service_level' => $cached_site['service_level'], 'framework' => $cached_site['framework'], 'created' => date('Y-m-d H:i:s', $cached_site['created']), 'memberships' => array_map(function ($membership) {
             return $membership['name'];
         }, array_values($cached_site['memberships'])));
     }, array_values($cached_sites));
     if (isset($assoc_args['team'])) {
         $rows = array_filter($rows, function ($site) {
             return in_array('Team', $site['memberships']);
         });
     }
     if (isset($assoc_args['org'])) {
         $org_id = $assoc_args['org'];
         $rows = array_filter($rows, function ($site) use($org_id) {
             $org_ids = array_keys($site['memberships']);
             return in_array($org_id, $org_ids);
         });
     }
     if (count($rows) == 0) {
         Terminus::log("You have no sites.");
         exit(0);
     }
     $this->handleDisplay($rows);
 }
开发者ID:rvtraveller,项目名称:terminus,代码行数:42,代码来源:sites.php

示例2: index

 /**
  * Show all sites user has access to
  * Note: because of the size of this call, it is cached
  *   and also is the basis for loading individual sites by name
  *
  * [--team]
  * : filter sites you are a team member of
  *
  * [--org=<id>]
  * : filter sites you can access via the organization
  *
  * @subcommand list
  * @alias show
  */
 public function index($args, $assoc_args)
 {
     // Always fetch a fresh list of sites
     $this->sites->rebuildCache();
     $sites = $this->sites->all();
     $rows = array();
     foreach ($sites as $site) {
         $memberships = array();
         foreach ($site->get('memberships') as $membership) {
             $memberships[$membership['id']] = $membership['name'];
         }
         $rows[$site->get('id')] = array('name' => $site->get('name'), 'id' => $site->get('id'), 'service_level' => $site->get('service_level'), 'framework' => $site->get('framework'), 'created' => date('Y-m-d H:i:s', $site->get('created')), 'memberships' => $memberships);
     }
     usort($rows, function ($row_1, $row_2) {
         return strcasecmp($row_1['name'], $row_2['name']);
     });
     if (isset($assoc_args['team'])) {
         $rows = array_filter($rows, function ($site) {
             return in_array('Team', $site['memberships']);
         });
     }
     if (isset($assoc_args['org'])) {
         $org_id = $assoc_args['org'];
         $rows = array_filter($rows, function ($site) use($org_id) {
             return isset($org_ids[$org_id]) || in_array($org_id, $site['memberships']);
         });
     }
     if (count($rows) == 0) {
         Terminus::log('You have no sites.');
     }
     $labels = ['name' => 'Name', 'id', 'ID', 'service_level', 'Service Level', 'framework' => 'Framework', 'created' => 'Created', 'memberships' => 'Memberships'];
     $this->outputter->outputRecordList($rows, $labels);
 }
开发者ID:newtoid,项目名称:cli,代码行数:47,代码来源:sites.php

示例3: 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::get_cache();
         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::get_config('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:nataliejeremy,项目名称:cli,代码行数:43,代码来源:class-terminus-command.php

示例4: _fetch_sites

 /**
  * Actually go out and get the sites.
  */
 protected function _fetch_sites()
 {
     Terminus::log('Fetching site list from Pantheon');
     $request = self::request('user', Session::getValue('user_uuid'), 'sites', 'GET', array('hydrated' => true));
     # TODO: handle errors well.
     $sites = $request['data'];
     $this->cache->put_data('sites', $sites);
     $this->sites = $sites;
     return $sites;
 }
开发者ID:mikevanwinkle,项目名称:cli,代码行数:13,代码来源:class-terminus-command.php

示例5: get_runner

 static function get_runner()
 {
     // the entire process needs an exception wrapper
     try {
         static $runner;
         if (!isset($runner) || !$runner) {
             $runner = new Runner();
         }
         return $runner;
     } catch (\Exception $e) {
         Terminus::log('error', $e->getMessage());
         exit(1);
     }
 }
开发者ID:nataliejeremy,项目名称:cli,代码行数:14,代码来源:class-terminus.php

示例6: index

 /**
  * Show all sites user has access to
  * Note: because of the size of this call, it is cached
  *   and also is the basis for loading individual sites by name
  *
  * @subcommand list
  * @alias show
  */
 public function index($args, $assoc_args)
 {
     // Always fetch a fresh list of sites
     $this->sitesCache->rebuild();
     $cached_sites = $this->sitesCache->all();
     if (count($cached_sites) == 0) {
         Terminus::log("You have no sites.");
         exit(0);
     }
     $rows = array_map(function ($cached_site) {
         return array('name' => $cached_site['name'], 'id' => $cached_site['id'], 'service_level' => $cached_site['service_level'], 'framework' => $cached_site['framework'], 'memberships' => array_map(function ($membership) {
             return $membership['name'];
         }, $cached_site['memberships']));
     }, $cached_sites);
     $this->handleDisplay($rows);
     return $rows;
 }
开发者ID:reynoldsalec,项目名称:cli,代码行数:25,代码来源:sites.php

示例7: send

 public static function send($url, $method, $data = array())
 {
     // create a new Guzzle\Http\Client
     $browser = new Browser();
     $browser->setUserAgent(self::userAgent());
     $options = array('allow_redirects' => false, 'verify' => false, 'json' => false);
     if (isset($data['allow_redirects'])) {
         $options['allow_redirects'] = $data['allow_redirects'];
     }
     if (isset($data['json'])) {
         $options['json'] = $data['json'];
     }
     if (isset($data['body']) && $data['body']) {
         $options['body'] = $data['body'];
         if (\Terminus::get_config('debug')) {
             \Terminus::log('debug', $data['body']);
         }
     }
     $request = $browser->createRequest($method, $url, null, null, $options);
     if (!empty($data['postdata'])) {
         foreach ($data['postdata'] as $k => $v) {
             $request->setPostField($k, $v);
         }
     }
     if (!empty($data['cookies'])) {
         foreach ($data['cookies'] as $k => $v) {
             $request->addCookie($k, $v);
         }
     }
     if (!empty($data['headers'])) {
         foreach ($data['headers'] as $k => $v) {
             $request->setHeader($k, $v);
         }
     }
     if (\Terminus::get_config("debug")) {
         $debug = "#### REQUEST ####" . PHP_EOL;
         $debug .= $request->getRawHeaders();
         \Terminus::log('debug', $debug);
         if (isset($data['body'])) {
             \Terminus::log('debug', $data['body']);
         }
     }
     $response = $request->send();
     return $response;
 }
开发者ID:jalama,项目名称:cli,代码行数:45,代码来源:Request.php

示例8: invalid_positionals

 public function invalid_positionals($args)
 {
     $positionals = $this->query_spec(array('type' => 'positional'));
     for ($i = 0; $i < count($args); $i++) {
         if (!isset($positionals[$i]['token'])) {
             continue;
         }
         $token = preg_replace('#\\[?\\<([a-zA-Z].*)\\>\\]?.*#s', '$1', $positionals[$i]['token']);
         if ("commands" == trim($token) || "email" == trim($token)) {
             // we exit here because the wp and drush commands need to not have validation running since their commands are dependent on their respective code bases.
             return false;
         }
         $regex = "#^({$token})\$#s";
         \Terminus::log('debug', "Positional match {$regex}");
         if (!preg_match($regex, $args[$i])) {
             return $args[$i];
         }
     }
     return false;
 }
开发者ID:nataliejeremy,项目名称:cli,代码行数:20,代码来源:SynopsisValidator.php

示例9: validate_args

 /**
  * @return array list of invalid $assoc_args keys to unset
  */
 private function validate_args($args, $assoc_args, $extra_args)
 {
     $synopsis = $this->get_synopsis();
     if (!$synopsis) {
         return array();
     }
     $validator = new \Terminus\SynopsisValidator($synopsis);
     $cmd_path = implode(' ', get_path($this));
     foreach ($validator->get_unknown() as $token) {
         \Terminus::log('warning', "The `{cmd}` command has an invalid synopsis part: {token}", array('cmd' => $cmd_path, 'token' => $token));
     }
     if (!$validator->enough_positionals($args)) {
         $this->show_usage();
         exit(1);
     }
     if ($this->name != 'help') {
         $invalid = $validator->invalid_positionals($args);
         if ($invalid) {
             throw new TerminusException("Invalid positional value: {invalid}", array('invalid' => $invalid));
         }
     }
     $unknown_positionals = $validator->unknown_positionals($args);
     if (!empty($unknown_positionals)) {
         throw new TerminusException('Too many positional arguments: {args}', array('args' => implode(' ', $unknown_positionals)));
     }
     list($errors, $to_unset) = $validator->validate_assoc(array_merge(\Terminus::get_config(), $extra_args, $assoc_args));
     foreach ($validator->unknown_assoc($assoc_args) as $key) {
         $errors['fatal'][] = "unknown --{$key} parameter";
     }
     if (!empty($errors['fatal'])) {
         $out = 'Parameter errors:';
         foreach ($errors['fatal'] as $error) {
             $out .= "\n " . $error;
         }
         throw new TerminusException($out);
     }
     foreach ($errors['warning'] as $warning) {
         \Terminus::log('warning', $warning);
     }
     return $to_unset;
 }
开发者ID:jalama,项目名称:cli,代码行数:44,代码来源:Subcommand.php


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