本文整理汇总了PHP中app\Auth::setToken方法的典型用法代码示例。如果您正苦于以下问题:PHP Auth::setToken方法的具体用法?PHP Auth::setToken怎么用?PHP Auth::setToken使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Auth
的用法示例。
在下文中一共展示了Auth::setToken方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parseInput
private function parseInput(InputInterface $input, OutputInterface $output)
{
/** @var QuestionHelper $helper */
$helper = $this->getHelper('question');
/*
* Filename
*/
$this->filename = $input->getOption('filename');
if (empty($this->filename)) {
$this->filename = $helper->ask($input, $output, new Question('Json file to import: '));
}
if (!file_exists($this->filename)) {
throw new \Exception('File not found');
}
/*
* Owner
*/
$this->owner = $input->getOption('owner');
if (empty($this->owner)) {
$this->owner = $helper->ask($input, $output, new Question('Owner of GitHub repository, organization or a person: '));
}
if (empty($this->owner)) {
throw new \Exception('Empty owner');
}
/*
* Repo
*/
$this->repo = $input->getOption('repo');
if (empty($this->repo)) {
$this->repo = $helper->ask($input, $output, new Question('GitHub repository name: '));
}
if (empty($this->repo)) {
throw new \Exception('Empty repo');
}
/*
* username
*/
$username = $input->getOption('username');
if (empty($username)) {
$username = $helper->ask($input, $output, new Question('GitHub username to log in with: '));
}
if (empty($username)) {
throw new \Exception('Empty username');
}
$this->auth = new Auth($username);
if ($helper->ask($input, $output, new Question('Do you use 2 factor auth for GitHub? (y/N) '))) {
$question = new Question('GitHub personal token (https://github.com/settings/tokens) with repo access: ');
$token = $helper->ask($input, $output, $question);
$this->auth->setToken($token);
} else {
$password = $helper->ask($input, $output, new Question('GitHub password: '));
$this->auth->setPassword($password);
}
}