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


PHP IOInterface::askAndHideAnswer方法代码示例

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


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

示例1: doAuthDance

 /**
  * Repositories requests credentials, let's put them in.
  *
  * @return \Composer\Util\Svn
  */
 protected function doAuthDance()
 {
     $this->io->write("The Subversion server ({$this->url}) requested credentials:");
     $this->hasAuth = true;
     $this->credentials['username'] = $this->io->ask("Username: ");
     $this->credentials['password'] = $this->io->askAndHideAnswer("Password: ");
     $this->cacheCredentials = $this->io->askConfirmation("Should Subversion cache these credentials? (yes/no) ", true);
     return $this;
 }
开发者ID:romainneutron,项目名称:composer,代码行数:14,代码来源:Svn.php

示例2: get

 /**
  * Get a patch-data
  *
  * @param   string          $section
  * @param   string          $key
  * @param   string          $ask
  * @param   string          $default
  * @param   string|callable $validator
  * @param   int|false       $attempts
  * @param   bool            $throwIfEmpty
  * @return  string
  * @throws  Exception\DomainException
  */
 public function get($section, $key, $ask = null, $default = null, $validator = null, $attempts = 3, $throwIfEmpty = true)
 {
     if (!empty($this->data[$section][$key])) {
         return $this->data[$section][$key];
     }
     if (!$this->io->isInteractive() || empty($ask)) {
         $result = $default;
     } else {
         $question = (string) $ask;
         if (null !== $default) {
             $question .= ' (default: <info>' . $default . '</info>)';
         }
         $ask = static::PADDING . $question . ': ';
         $hidden = false;
         if (true === $validator) {
             $hidden = true;
             $validator = null;
         }
         if (is_string($validator) && !function_exists($validator)) {
             $pattern = (string) $validator;
             $validator = function ($value) use($pattern) {
                 $matches = array();
                 if (!preg_match($pattern, $value, $matches)) {
                     throw new LogicException(sprintf('"%s" does not match "%s"', $value, $pattern));
                 }
                 return $matches[0];
             };
         }
         if (is_array($validator) && (count($validator) != 2 || !function_exists($validator))) {
             $values = (array) $validator;
             $validator = function ($value) use($values) {
                 if (!in_array($value, $values)) {
                     throw new LogicException(sprintf('"%s" is not available, only "%s" accepted', $value, implode('", "', $values)));
                 }
                 return $value;
             };
         }
         if (is_callable($validator)) {
             $result = $this->io->askAndValidate($ask, $validator, $attempts, $default);
         } else {
             if ($hidden) {
                 $result = $this->io->askAndHideAnswer($ask) ?: $default;
             } else {
                 $result = $this->io->ask($ask, $default);
             }
         }
     }
     if (empty($result)) {
         if ($throwIfEmpty) {
             throw new Exception\DomainException(sprintf('%s: patch-data "%s": "%s", asked as "%s" should not be empty', __METHOD__, $section, $key, $ask));
         }
     } else {
         $this->data[$section][$key] = $result;
     }
     return $result;
 }
开发者ID:gridguyz,项目名称:module-installer,代码行数:69,代码来源:PatchData.php

示例3: doAuthDance

 /**
  * Repositories requests credentials, let's put them in.
  *
  * @throws \RuntimeException
  * @return \Composer\Util\Svn
  */
 protected function doAuthDance()
 {
     // cannot ask for credentials in non interactive mode
     if (!$this->io->isInteractive()) {
         throw new \RuntimeException('can not ask for authentication in non interactive mode');
     }
     $this->io->writeError("The Subversion server ({$this->url}) requested credentials:");
     $this->hasAuth = true;
     $this->credentials['username'] = $this->io->ask("Username: ");
     $this->credentials['password'] = $this->io->askAndHideAnswer("Password: ");
     $this->cacheCredentials = $this->io->askConfirmation("Should Subversion cache these credentials? (yes/no) ", true);
     return $this;
 }
开发者ID:alancleaver,项目名称:composer,代码行数:19,代码来源:Svn.php

示例4: genSecretConfig

 /**
  * Generate database config. will store in: etc/secret.yml.
  *
  * @param IOInterface $io
  *
  * @return  void
  */
 protected static function genSecretConfig(IOInterface $io)
 {
     $etc = __DIR__ . '/../../../etc';
     $secret = Yaml::parse(file_get_contents($etc . '/secret.dist.yml'));
     $driver = 'mysql';
     $host = $io->ask("Database host [localhost]: ", 'localhost');
     $name = $io->ask("Database name [natika]: ", 'natika');
     $user = $io->ask("Database user [root]: ", 'root');
     $pass = $io->askAndHideAnswer("Database password: ");
     $prefix = '';
     $secret['database'] = array('driver' => $driver, 'host' => $host, 'user' => $user, 'password' => $pass, 'name' => $name, 'prefix' => $prefix);
     file_put_contents($etc . '/secret.yml', Yaml::dump($secret, 4));
     $io->write('');
     $io->write('Database config setting complete.');
     $io->write('');
 }
开发者ID:asika32764,项目名称:natika,代码行数:23,代码来源:StarterInstaller.php

示例5: start

 public static function start(Configuration $configuration, IOInterface $io)
 {
     $params = array();
     $params['database-model'] = $io->ask("> Database model? (MYSQLI) ", "MYSQLI");
     $params['database-host'] = $io->ask("> Database host? (localhost) ", "localhost");
     $params['database-port'] = $io->askAndValidate("> Database port? (3306) ", function ($value) {
         return is_int($value);
     }, 3, 3306);
     $params['database-name'] = $io->ask("> Database name? (comodojo) ", "comodojo");
     $params['database-user'] = $io->ask("> Database user? (comodojo) ", "comodojo");
     $params['database-password'] = $io->askAndHideAnswer("> Database password? ");
     $params['database-prefix'] = $io->ask("> Common prefix for database tables? (cmdj_) ", "cmdj_");
     foreach ($params as $param => $value) {
         $configuration->set($param, $value);
     }
 }
开发者ID:comodojo,项目名称:comodojo-installer,代码行数:16,代码来源:InteractiveConfiguration.php

示例6: genSecretConfig

 /**
  * Generate database config. will store in: etc/secret.yml.
  *
  * @param IOInterface $io
  *
  * @return  void
  */
 protected static function genSecretConfig(IOInterface $io)
 {
     $etc = __DIR__ . '/../../../etc';
     $secret = Yaml::parse(file_get_contents($etc . '/secret.dist.yml'));
     if ($io->askConfirmation("\nDo you want to use database? [Y/n]: ", true)) {
         $io->write('');
         $io->write('Database driver only support mysql/postgresql now.');
         $driver = $io->ask("Database driver [mysql]: ", 'mysql');
         $host = $io->ask("Database host [localhost]: ", 'localhost');
         $name = $io->ask("Database name [acme]: ", 'acme');
         $user = $io->ask("Database user [root]: ", 'root');
         $pass = $io->askAndHideAnswer("Database password: ");
         $prefix = $io->ask("Table prefix [wind_]: ", 'wind_');
         $secret['database'] = array('driver' => $driver, 'host' => $host, 'user' => $user, 'password' => $pass, 'name' => $name, 'prefix' => $prefix);
     }
     file_put_contents($etc . '/secret.yml', Yaml::dump($secret, 4));
     $io->write('');
     $io->write('Database config setting complete.');
     $io->write('');
 }
开发者ID:lyrasoft,项目名称:earth,代码行数:27,代码来源:StarterInstaller.php

示例7: runCommand

 public function runCommand($commandCallable, $url, $cwd, $initialClone = false)
 {
     if (preg_match('{^(http|git):}i', $url) && $this->config->get('secure-http')) {
         throw new TransportException("Your configuration does not allow connection to {$url}. See https://getcomposer.org/doc/06-config.md#secure-http for details.");
     }
     if ($initialClone) {
         $origCwd = $cwd;
         $cwd = null;
     }
     if (preg_match('{^ssh://[^@]+@[^:]+:[^0-9]+}', $url)) {
         throw new \InvalidArgumentException('The source URL ' . $url . ' is invalid, ssh URLs should have a port number after ":".' . "\n" . 'Use ssh://git@example.com:22/path or just git@example.com:path if you do not want to provide a password or custom port.');
     }
     if (!$initialClone) {
         // capture username/password from URL if there is one
         $this->process->execute('git remote -v', $output, $cwd);
         if (preg_match('{^(?:composer|origin)\\s+https?://(.+):(.+)@([^/]+)}im', $output, $match)) {
             $this->io->setAuthentication($match[3], urldecode($match[1]), urldecode($match[2]));
         }
     }
     $protocols = $this->config->get('github-protocols');
     if (!is_array($protocols)) {
         throw new \RuntimeException('Config value "github-protocols" must be an array, got ' . gettype($protocols));
     }
     // public github, autoswitch protocols
     if (preg_match('{^(?:https?|git)://' . self::getGitHubDomainsRegex($this->config) . '/(.*)}', $url, $match)) {
         $messages = array();
         foreach ($protocols as $protocol) {
             if ('ssh' === $protocol) {
                 $protoUrl = "git@" . $match[1] . ":" . $match[2];
             } else {
                 $protoUrl = $protocol . "://" . $match[1] . "/" . $match[2];
             }
             if (0 === $this->process->execute(call_user_func($commandCallable, $protoUrl), $ignoredOutput, $cwd)) {
                 return;
             }
             $messages[] = '- ' . $protoUrl . "\n" . preg_replace('#^#m', '  ', $this->process->getErrorOutput());
             if ($initialClone) {
                 $this->filesystem->removeDirectory($origCwd);
             }
         }
         // failed to checkout, first check git accessibility
         $this->throwException('Failed to clone ' . self::sanitizeUrl($url) . ' via ' . implode(', ', $protocols) . ' protocols, aborting.' . "\n\n" . implode("\n", $messages), $url);
     }
     // if we have a private github url and the ssh protocol is disabled then we skip it and directly fallback to https
     $bypassSshForGitHub = preg_match('{^git@' . self::getGitHubDomainsRegex($this->config) . ':(.+?)\\.git$}i', $url) && !in_array('ssh', $protocols, true);
     $command = call_user_func($commandCallable, $url);
     $auth = null;
     if ($bypassSshForGitHub || 0 !== $this->process->execute($command, $ignoredOutput, $cwd)) {
         // private github repository without git access, try https with auth
         if (preg_match('{^git@' . self::getGitHubDomainsRegex($this->config) . ':(.+?)\\.git$}i', $url, $match)) {
             if (!$this->io->hasAuthentication($match[1])) {
                 $gitHubUtil = new GitHub($this->io, $this->config, $this->process);
                 $message = 'Cloning failed using an ssh key for authentication, enter your GitHub credentials to access private repos';
                 if (!$gitHubUtil->authorizeOAuth($match[1]) && $this->io->isInteractive()) {
                     $gitHubUtil->authorizeOAuthInteractively($match[1], $message);
                 }
             }
             if ($this->io->hasAuthentication($match[1])) {
                 $auth = $this->io->getAuthentication($match[1]);
                 $authUrl = 'https://' . rawurlencode($auth['username']) . ':' . rawurlencode($auth['password']) . '@' . $match[1] . '/' . $match[2] . '.git';
                 $command = call_user_func($commandCallable, $authUrl);
                 if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) {
                     return;
                 }
             }
         } elseif ($this->isAuthenticationFailure($url, $match)) {
             // private non-github repo that failed to authenticate
             if (strpos($match[2], '@')) {
                 list($authParts, $match[2]) = explode('@', $match[2], 2);
             }
             $storeAuth = false;
             if ($this->io->hasAuthentication($match[2])) {
                 $auth = $this->io->getAuthentication($match[2]);
             } elseif ($this->io->isInteractive()) {
                 $defaultUsername = null;
                 if (isset($authParts) && $authParts) {
                     if (false !== strpos($authParts, ':')) {
                         list($defaultUsername, ) = explode(':', $authParts, 2);
                     } else {
                         $defaultUsername = $authParts;
                     }
                 }
                 $this->io->writeError('    Authentication required (<info>' . parse_url($url, PHP_URL_HOST) . '</info>):');
                 $auth = array('username' => $this->io->ask('      Username: ', $defaultUsername), 'password' => $this->io->askAndHideAnswer('      Password: '));
                 $storeAuth = $this->config->get('store-auths');
             }
             if ($auth) {
                 $authUrl = $match[1] . rawurlencode($auth['username']) . ':' . rawurlencode($auth['password']) . '@' . $match[2] . $match[3];
                 $command = call_user_func($commandCallable, $authUrl);
                 if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) {
                     $this->io->setAuthentication($match[2], $auth['username'], $auth['password']);
                     $authHelper = new AuthHelper($this->io, $this->config);
                     $authHelper->storeAuth($match[2], $storeAuth);
                     return;
                 }
             }
         }
         if ($initialClone) {
             $this->filesystem->removeDirectory($origCwd);
         }
//.........这里部分代码省略.........
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:101,代码来源:Git.php

示例8: queryP4Password

 public function queryP4Password(IOInterface $io)
 {
     if (isset($this->p4Password)) {
         return $this->p4Password;
     }
     $password = $this->getP4variable('P4PASSWD');
     if (strlen($password) <= 0) {
         $password = $io->askAndHideAnswer('Enter password for Perforce user ' . $this->getUser() . ': ');
     }
     $this->p4Password = $password;
     return $password;
 }
开发者ID:itillawarra,项目名称:cmfive,代码行数:12,代码来源:Perforce.php

示例9: promptAuth

 public function promptAuth(HttpGetResponse $res, CConfig $config, IO\IOInterface $io)
 {
     $httpCode = $res->info['http_code'];
     // 404s are only handled for github
     if (404 === $httpCode) {
         return false;
     }
     // fail if the console is not interactive
     if (!$io->isInteractive()) {
         switch ($httpCode) {
             case 401:
                 $message = "The '{$this->getURL()}' URL required authentication.\nYou must be using the interactive console to authenticate";
                 break;
             case 403:
                 $message = "The '{$this->getURL()}' URL could not be accessed.";
                 break;
         }
         throw new Downloader\TransportException($message, $httpCode);
     }
     // fail if we already have auth
     if ($io->hasAuthentication($this->origin)) {
         throw new Downloader\TransportException("Invalid credentials for '{$this->getURL()}', aborting.", $httpCode);
     }
     $io->overwrite("    Authentication required (<info>{$this->host}</info>):");
     $username = $io->ask('      Username: ');
     $password = $io->askAndHideAnswer('      Password: ');
     $io->setAuthentication($this->origin, $username, $password);
     return true;
 }
开发者ID:k0pernikus,项目名称:prestissimo,代码行数:29,代码来源:HttpGetRequest.php


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