Path

ez components / documentation / api reference / 2009.2.1 / consoletools


eZ Components 2009.2.1

ConsoleTools: ezcConsoleMenuDialog

[ Tutorial ] [ Class tree ] [ Element index ] [ ChangeLog ] [ Credits ]

Class: ezcConsoleMenuDialog

Dialog class to make the user choose from a menu. [source]

Implemented Interfaces

This dialog implementation displays a menu structure to the user and receives a valid menu selection.
The behaviour of this dialog is defined by an instance of ezcConsoleMenuDialogOptions.

Member Variables

protected array $properties = array(
"options" => null,
"output" => null,
)

Properties
protected mixed $result
Dialog result

Method Summary

public void __construct( $output, [$options = null] )
Creates a new menu dialog.
public void display( )
Displays the dialog and retreives a value from the user.
public mixed getResult( )
Returns the result retrieved.
public bool hasValidResult( )
Returns if the dialog retrieved a valid result.
public void reset( )
Reset the dialog.

Methods

__construct

void __construct( ezcConsoleOutput $output, [ezcConsoleMenuDialogOptions $options = null] )
Creates a new menu dialog.
Creates a new question dialog to be displayed to the user. All behaviour is defined through the $options parameter. The $output parameter is used to display the dialog in the display() method.

Parameters

Name Type Description
$output ezcConsoleOutput Output object.
$options ezcConsoleMenuDialogOptions The options.

display

void display( )
Displays the dialog and retreives a value from the user.
Displays the dialog and retreives the desired answer from the user. If the a valid result is retrieved, it can be obtained using getResult(). The method hasValidResult() can be used to check if a valid result is available.

Throws

ClassDescription
ezcConsoleDialogAbortException if the user closes STDIN using <CTRL>-D.

getResult

mixed getResult( )
Returns the result retrieved.
If no valid result was retreived, yet, this method throws an ezcConsoleNoValidDialogResultException. Use hasValidResult() to avoid this.

Throws

ClassDescription
ezcDialogNoValidResultException if this method is called without a valid result being retrieved by the object. Use hasValidResult() to avoid this exception.

hasValidResult

bool hasValidResult( )
Returns if the dialog retrieved a valid result.
If a valid result has already been received, this method returns true, otherwise false.

reset

void reset( )
Reset the dialog.
Resets a possibly received result and all changes made to the dialog during display(). After that, the dialog can be re-used. All option values are kept.

Last updated: Tue, 23 Mar 2010