PHP 클래스 Cake\Console\ConsoleIo

Packages up the stdout, stderr, and stdin streams providing a simple consistent interface for shells to use. This class also makes mocking streams easy to do in unit tests.
파일 보기 프로젝트 열기: cakephp/cakephp 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$_err ConsoleOutput The error stream
$_helpers Cake\Console\HelperRegistry The helper registry.
$_in Cake\Console\ConsoleInput The input stream
$_lastWritten integer The number of bytes last written to the output stream used when overwriting the previous message.
$_level integer The current output level.
$_out ConsoleOutput The output stream

공개 메소드들

메소드 설명
__construct ( ConsoleOutput $out = null, ConsoleOutput $err = null, Cake\Console\ConsoleInput $in = null, Cake\Console\HelperRegistry $helpers = null ) Constructor
ask ( string $prompt, string | null $default = null ) : mixed Prompts the user for input, and returns it.
askChoice ( string $prompt, string | array $options, string | null $default = null ) : mixed Prompts the user for input based on a list of options, and returns it.
err ( string | array $message = '', integer $newlines = 1 ) : integer | boolean Outputs a single or multiple error messages to stderr. If no parameters are passed outputs just a newline.
helper ( string $name, array $settings = [] ) : Cake\Console\Helper Render a Console Helper
hr ( integer $newlines, integer $width = 79 ) : void Outputs a series of minus characters to the standard output, acts as a visual separator.
level ( null | integer $level = null ) : integer Get/set the current output level.
nl ( integer $multiplier = 1 ) : string Returns a single or multiple linefeeds sequences.
out ( string | array $message = '', integer $newlines = 1, integer $level = ConsoleIo::NORMAL ) : integer | boolean Outputs a single or multiple messages to stdout. If no parameters are passed outputs just a newline.
outputAs ( integer $mode ) : void Change the output mode of the stdout stream
overwrite ( array | string $message, integer $newlines = 1, integer | null $size = null ) : void Overwrite some already output text.
quiet ( string | array $message, integer $newlines = 1 ) : integer | boolean Output at all levels.
setLoggers ( integer | boolean $enable ) : void Connects or disconnects the loggers to the console output.
styles ( string | null $style = null, array | boolean | null $definition = null ) : mixed Add a new output style or get defined styles.
verbose ( string | array $message, integer $newlines = 1 ) : integer | boolean Output at the verbose level.

보호된 메소드들

메소드 설명
_getInput ( string $prompt, string | null $options, string | null $default ) : string Prompts the user for input, and returns it.

메소드 상세

__construct() 공개 메소드

Constructor
public __construct ( ConsoleOutput $out = null, ConsoleOutput $err = null, Cake\Console\ConsoleInput $in = null, Cake\Console\HelperRegistry $helpers = null )
$out ConsoleOutput A ConsoleOutput object for stdout.
$err ConsoleOutput A ConsoleOutput object for stderr.
$in Cake\Console\ConsoleInput A ConsoleInput object for stdin.
$helpers Cake\Console\HelperRegistry A HelperRegistry instance

_getInput() 보호된 메소드

Prompts the user for input, and returns it.
protected _getInput ( string $prompt, string | null $options, string | null $default ) : string
$prompt string Prompt text.
$options string | null String of options. Pass null to omit.
$default string | null Default input value. Pass null to omit.
리턴 string Either the default value, or the user-provided input.

ask() 공개 메소드

Prompts the user for input, and returns it.
public ask ( string $prompt, string | null $default = null ) : mixed
$prompt string Prompt text.
$default string | null Default input value.
리턴 mixed Either the default value, or the user-provided input.

askChoice() 공개 메소드

Prompts the user for input based on a list of options, and returns it.
public askChoice ( string $prompt, string | array $options, string | null $default = null ) : mixed
$prompt string Prompt text.
$options string | array Array or string of options.
$default string | null Default input value.
리턴 mixed Either the default value, or the user-provided input.

err() 공개 메소드

Outputs a single or multiple error messages to stderr. If no parameters are passed outputs just a newline.
public err ( string | array $message = '', integer $newlines = 1 ) : integer | boolean
$message string | array A string or an array of strings to output
$newlines integer Number of newlines to append
리턴 integer | boolean The number of bytes returned from writing to stderr.

helper() 공개 메소드

Create and render the output for a helper object. If the helper object has not already been loaded, it will be loaded and constructed.
public helper ( string $name, array $settings = [] ) : Cake\Console\Helper
$name string The name of the helper to render
$settings array Configuration data for the helper.
리턴 Cake\Console\Helper The created helper instance.

hr() 공개 메소드

Outputs a series of minus characters to the standard output, acts as a visual separator.
public hr ( integer $newlines, integer $width = 79 ) : void
$newlines integer Number of newlines to pre- and append
$width integer Width of the line, defaults to 79
리턴 void

level() 공개 메소드

Get/set the current output level.
public level ( null | integer $level = null ) : integer
$level null | integer The current output level.
리턴 integer The current output level.

nl() 공개 메소드

Returns a single or multiple linefeeds sequences.
public nl ( integer $multiplier = 1 ) : string
$multiplier integer Number of times the linefeed sequence should be repeated
리턴 string

out() 공개 메소드

### Output levels There are 3 built-in output level. Shell::QUIET, Shell::NORMAL, Shell::VERBOSE. The verbose and quiet output levels, map to the verbose and quiet output switches present in most shells. Using Shell::QUIET for a message means it will always display. While using Shell::VERBOSE means it will only display when verbose output is toggled.
public out ( string | array $message = '', integer $newlines = 1, integer $level = ConsoleIo::NORMAL ) : integer | boolean
$message string | array A string or an array of strings to output
$newlines integer Number of newlines to append
$level integer The message's output level, see above.
리턴 integer | boolean The number of bytes returned from writing to stdout.

outputAs() 공개 메소드

Change the output mode of the stdout stream
또한 보기: Cake\Console\ConsoleOutput::outputAs()
public outputAs ( integer $mode ) : void
$mode integer The output mode.
리턴 void

overwrite() 공개 메소드

Useful for building progress bars, or when you want to replace text already output to the screen with new text. **Warning** You cannot overwrite text that contains newlines.
public overwrite ( array | string $message, integer $newlines = 1, integer | null $size = null ) : void
$message array | string The message to output.
$newlines integer Number of newlines to append.
$size integer | null The number of bytes to overwrite. Defaults to the length of the last message output.
리턴 void

quiet() 공개 메소드

Output at all levels.
public quiet ( string | array $message, integer $newlines = 1 ) : integer | boolean
$message string | array A string or an array of strings to output
$newlines integer Number of newlines to append
리턴 integer | boolean The number of bytes returned from writing to stdout.

setLoggers() 공개 메소드

Used to enable or disable logging stream output to stdout and stderr If you don't wish all log output in stdout or stderr through Cake's Log class, call this function with $enable=false.
public setLoggers ( integer | boolean $enable ) : void
$enable integer | boolean Use a boolean to enable/toggle all logging. Use one of the verbosity constants (self::VERBOSE, self::QUIET, self::NORMAL) to control logging levels. VERBOSE enables debug logs, NORMAL does not include debug logs, QUIET disables notice, info and debug logs.
리턴 void

styles() 공개 메소드

Add a new output style or get defined styles.
또한 보기: Cake\Console\ConsoleOutput::styles()
public styles ( string | null $style = null, array | boolean | null $definition = null ) : mixed
$style string | null The style to get or create.
$definition array | boolean | null The array definition of the style to change or create a style or false to remove a style.
리턴 mixed If you are getting styles, the style or null will be returned. If you are creating/modifying styles true will be returned.

verbose() 공개 메소드

Output at the verbose level.
public verbose ( string | array $message, integer $newlines = 1 ) : integer | boolean
$message string | array A string or an array of strings to output
$newlines integer Number of newlines to append
리턴 integer | boolean The number of bytes returned from writing to stdout.

프로퍼티 상세

$_err 보호되어 있는 프로퍼티

The error stream
protected ConsoleOutput,Cake\Console $_err
리턴 ConsoleOutput

$_helpers 보호되어 있는 프로퍼티

The helper registry.
protected HelperRegistry,Cake\Console $_helpers
리턴 Cake\Console\HelperRegistry

$_in 보호되어 있는 프로퍼티

The input stream
protected ConsoleInput,Cake\Console $_in
리턴 Cake\Console\ConsoleInput

$_lastWritten 보호되어 있는 프로퍼티

The number of bytes last written to the output stream used when overwriting the previous message.
protected int $_lastWritten
리턴 integer

$_level 보호되어 있는 프로퍼티

The current output level.
protected int $_level
리턴 integer

$_out 보호되어 있는 프로퍼티

The output stream
protected ConsoleOutput,Cake\Console $_out
리턴 ConsoleOutput