Default validator for ezcConsoleMenuDialog.
This dialog contains a set of menu entries, defined in the $elements property. The result, provided by the user, is checked against the keys of this array. A conversion can be specified to relax the rules for validation (like coverting the result to lower case first). For possibly conversions see the CONVERT_* constants in this class If the user does not provide an answer, a possibly set default value is used.
Source for this file: /ConsoleTools/src/dialog/validators/menu_dialog_default.php
Version: | //autogen// |
int | read/write |
$conversion
ezcConsoleDialogValidator::CONVERT_NONE (default) or ezcConsoleDialogValidator::CONVERT_LOWER or ezcConsoleDialogValidator::CONVERT_UPPER. |
string | read/write |
$default
The default value. |
array | read/write |
$elements
The elements of the menu. |
protected array |
$properties
= array(
Properties |
public void |
__construct(
[ $elements
= array()] , [ $default
= null] , [ $conversion
= self::CONVERT_NONE] )
Creates a new menu default validator. |
public mixed |
fixup(
$result
)
Returns a fixed version of the result, if possible. |
public array(string=>string) |
getElements(
)
Returns an array of the elements to display. |
public string |
getResultString(
)
Returns a string representing the default value. |
public bool |
validate(
$result
)
Returns if the given result is valid. |
Creates a new menu default validator.
Creates a validator specified by the given parameters. The $elements array specifies the possible menu items to select from. The item identifier (the key of the array) is used to validate the result. The assigned text is displayed as the menu item text. If no result is provided and an optionally provided default value is used. The $conversion parameter can be used to get a conversion applied to the result before validating it.
Name | Type | Description |
---|---|---|
$elements |
array | The elements of the menu. |
$default |
mixed | The default value. |
$conversion |
int | The conversion to apply. |
Returns a fixed version of the result, if possible.
Converts the given result according to the conversion defined in the $conversion property.
Name | Type | Description |
---|---|---|
$result |
mixed | The received result. |
Method | Description |
---|---|
ezcConsoleDialogValidator::fixup() |
Returns a fixed version of the result, if possible. |
Returns an array of the elements to display.
Method | Description |
---|---|
ezcConsoleMenuDialogValidator::getElements() |
Returns an array of the elements to display. |
Returns a string representing the default value.
For example "[y]" to indicate that "y" is the preselected result and will be chosen if no result is provided.
Method | Description |
---|---|
ezcConsoleQuestionDialogValidator::getResultString() |
Returns a string of possible results to be displayed with the question. |
Returns if the given result is valid.
Checks if the given result is a valid key in the $elements property.
Name | Type | Description |
---|---|---|
$result |
mixed | The received result. |
Method | Description |
---|---|
ezcConsoleDialogValidator::validate() |
Returns if the given result is valid. |