MIOLO20
Carregando...
Procurando...
Nenhuma entrada encontrada
DialogHelper.php
Ir para a documentação deste ficheiro.
1
<?php
2
3
namespace
Symfony\Component\Console\Helper
;
4
5
use
Symfony\Component\Console\Output\OutputInterface
;
6
7
/*
8
* This file is part of the Symfony framework.
9
*
10
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
11
*
12
* This source file is subject to the MIT license that is bundled
13
* with this source code in the file LICENSE.
14
*/
15
21
class
DialogHelper
extends
Helper
22
{
32
public
function
ask
(
OutputInterface
$output, $question, $default =
null
)
33
{
34
// @codeCoverageIgnoreStart
35
$output->writeln($question);
36
37
$ret = trim(fgets(STDIN));
38
39
return
$ret ? $ret : $default;
40
// @codeCoverageIgnoreEnd
41
}
42
54
public
function
askConfirmation
(
OutputInterface
$output, $question, $default =
true
)
55
{
56
// @codeCoverageIgnoreStart
57
$answer =
'z'
;
58
while
($answer && !in_array(strtolower($answer[0]), array(
'y'
,
'n'
))) {
59
$answer = $this->
ask
($output, $question);
60
}
61
62
if
(
false
=== $default) {
63
return
$answer &&
'y'
== strtolower($answer[0]);
64
}
else
{
65
return
!$answer ||
'y'
== strtolower($answer[0]);
66
}
67
// @codeCoverageIgnoreEnd
68
}
69
82
public
function
askAndValidate
(
OutputInterface
$output, $question, \Closure $validator, $attempts =
false
)
83
{
84
// @codeCoverageIgnoreStart
85
$error =
null
;
86
while
(
false
=== $attempts || $attempts--) {
87
if
(
null
!== $error) {
88
$output->writeln($this->
getHelperSet
()->
get
(
'formatter'
)->formatBlock($error->getMessage(),
'error'
));
89
}
90
91
$value = $this->
ask
($output, $question,
null
);
92
93
try
{
94
return
$validator($value);
95
}
catch
(\Exception $error) {
96
}
97
}
98
99
throw
$error;
100
// @codeCoverageIgnoreEnd
101
}
102
106
public
function
getName
()
107
{
108
return
'dialog'
;
109
}
110
}
Symfony\Component\Console\Helper\DialogHelper
Definição
DialogHelper.php:22
Symfony\Component\Console\Helper\DialogHelper\ask
ask(OutputInterface $output, $question, $default=null)
Definição
DialogHelper.php:32
Symfony\Component\Console\Helper\DialogHelper\getName
getName()
Definição
DialogHelper.php:106
Symfony\Component\Console\Helper\DialogHelper\askAndValidate
askAndValidate(OutputInterface $output, $question, \Closure $validator, $attempts=false)
Definição
DialogHelper.php:82
Symfony\Component\Console\Helper\DialogHelper\askConfirmation
askConfirmation(OutputInterface $output, $question, $default=true)
Definição
DialogHelper.php:54
Symfony\Component\Console\Helper\Helper
Definição
Helper.php:20
Symfony\Component\Console\Helper\Helper\getHelperSet
getHelperSet()
Definição
Helper.php:38
Symfony\Component\Console\Output\OutputInterface
Definição
OutputInterface.php:20
Symfony\Component\Console\Helper
Definição
DialogHelper.php:3
classes
extensions
doctrine-dbal
Doctrine
Symfony
Component
Console
Helper
DialogHelper.php
Gerado por
1.10.0