Apache Zeta Components Manual :: File Source for menu_dialog.php
Source for file menu_dialog.php
Documentation is available at menu_dialog.php
* File containing the ezcConsoleMenuDialog class.
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* @version //autogentag//
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* Dialog class to make the user choose from a menu.
* 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
* {@link ezcConsoleMenuDialogOptions}.
* 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 {@link display()} method.
* @param ezcConsoleOutput $output Output object.
* @param ezcConsoleMenuDialogOptions $options The options.
public function __construct( ezcConsoleOutput $output, ezcConsoleMenuDialogOptions $options =
null )
* Returns if the dialog retrieved a valid result.
* If a valid result has already been received, this method returns true,
* @return bool If a valid result was retrieved.
return ( $this->result !==
null );
* Returns the result retrieved.
* If no valid result was retreived, yet, this method throws an
* ezcConsoleNoValidDialogResultException. Use {@link hasValidResult()} to
* @return mixed The retreived result.
* @throws ezcDialogNoValidResultException
* if this method is called without a valid result being retrieved
* by the object. Use {@link hasValidResult()} to avoid this
* 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 {@link }
* getResult()}. The method {@link hasValidResult()} can be used to check
* if a valid result is available.
* @throws ezcConsoleDialogAbortException
* if the user closes STDIN using <CTRL>-D.
$text =
"{
$this->options->text}\n";
foreach ( $this->options->validator->getElements() as $key =>
$entry )
$this->options->formatString,
$text .=
"\n{$this->options->selectText}{
$this->options->validator->getResultString()} ";
$this->output->outputText( $text, $this->options->format );
$result =
$this->options->validator->fixup(
if ( $this->options->validator->validate( $result ) )
* Resets a possibly received result and all changes made to the dialog
* during {@link display()}. After that, the dialog can be re-used. All
* option values are kept.
* @throws ezcBasePropertyNotFoundException
* If the the desired property is not found.
* @param string $propertyName Name of the property.
* @return mixed Value of the property or null.
public function __get( $propertyName )
* @param string $propertyName Name of the property.
* @param mixed $propertyValue The value for the property.
* @throws ezcBasePropertyPermissionException
* If the property you try to access is read-only.
* @throws ezcBasePropertyNotFoundException
* If the the desired property is not found.
public function __set( $propertyName, $propertyValue )
"instance of ezcConsoleMenuDialogOptions"
"instance of ezcConsoleOutput"
$this->properties[$propertyName] =
$propertyValue;
* @param string $propertyName Name of the property to check.
* @return bool If the property exists or not.
public function __isset( $propertyName )