## Apache Zeta Components Manual :: File Source for question_dialog.php

## Source for file question_dialog.php

Documentation is available at question_dialog.php

1. <?php
2. /**
3. * File containing the ezcConsoleQuestionDialogOptions class.
4. *
5. * Licensed to the Apache Software Foundation (ASF) under one
6. * or more contributor license agreements. See the NOTICE file
7. * distributed with this work for additional information
8. * regarding copyright ownership. The ASF licenses this file
9. * to you under the Apache License, Version 2.0 (the
10. * "License"); you may not use this file except in compliance
11. * with the License. You may obtain a copy of the License at
12. *
13. * http://www.apache.org/licenses/LICENSE-2.0
14. *
15. * Unless required by applicable law or agreed to in writing,
16. * software distributed under the License is distributed on an
17. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18. * KIND, either express or implied. See the License for the
19. * specific language governing permissions and limitations
20. * under the License.
21. *
22. * @package ConsoleTools
23. * @version //autogentag//
24. * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
25. * @filesource
26. */
28. /**
29. * Basic options class for ezcConsoleDialog implementations.
30. *
31. * @package ConsoleTools
32. * @version //autogen//
33. *
34. * @property string $text
35. * The question itself.
36. * @property ezcConsoleQuestionDialogValidator $validator
37. * The validator to use with this dialog.
38. * @property bool $showResults
39. * Wether to display the possible results and the default selection.
40. * @property string $format
41. * The output format for the dialog.
42. */
43. class ezcConsoleQuestionDialogOptions extends ezcConsoleDialogOptions
44. {
46. /**
47. * Construct a new options object.
48. * Options are constructed from an option array by default. The constructor
49. * automatically passes the given options to the __set() method to set them
50. * in the class.
51. *
52. * @throws ezcBasePropertyNotFoundException
53. * If trying to access a non existent property.
54. * @throws ezcBaseValueException
55. * If the value for a property is out of range.
56. * @param array(string=>mixed) $options The initial options to set.
57. */
58. public function __construct ( array $options = array() )
59. {
60. $this-> properties ["text"] = "Please enter a value: ";
61. $this-> properties ["validator"] = new ezcConsoleQuestionDialogTypeValidator ();
62. $this-> properties ["showResults"] = false;
63. parent::__construct( $options );
64. }
66. /**
67. * Property write access.
68. *
69. * @param string $propertyName Name of the property.
70. * @param mixed $propertyValue The value for the property.
71. *
72. * @throws ezcBasePropertyPermissionException
73. * If the property you try to access is read-only.
74. * @throws ezcBasePropertyNotFoundException
75. * If the the desired property is not found.
76. * @ignore
77. */
78. public function __set( $propertyName, $propertyValue )
79. {
80. switch ( $propertyName )
81. {
82. case "text":
83. if ( is_string ( $propertyValue ) === false || strlen ( $propertyValue ) < 1 )
84. {
85. throw new ezcBaseValueException (
86. $propertyName,
87. $propertyValue,
88. "string, length > 0"
89. );
90. }
91. break;
92. case "showResults":
93. if ( is_bool ( $propertyValue ) === false )
94. {
95. throw new ezcBaseValueException ( $propertyName, $propertyValue, "bool" );
96. }
97. break;
98. case "validator":
99. if ( ( $propertyValue instanceof ezcConsoleQuestionDialogValidator ) === false )
100. {
101. throw new ezcBaseValueException ( $propertyName, $propertyValue, "ezcConsoleQuestionDialogValidator" );
102. }
103. break;
104. default:
105. parent::__set( $propertyName, $propertyValue );
106. return;
107. }
108. $this-> properties [$propertyName] = $propertyValue;
109. }
110. }
112. ?>

Documentation generated by phpDocumentor 1.4.3