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

## Source for file walk_context.php

Documentation is available at walk_context.php

1. <?php
2. /**
3. *
4. * Licensed to the Apache Software Foundation (ASF) under one
5. * or more contributor license agreements. See the NOTICE file
6. * distributed with this work for additional information
7. * regarding copyright ownership. The ASF licenses this file
8. * to you under the Apache License, Version 2.0 (the
9. * "License"); you may not use this file except in compliance
10. * with the License. You may obtain a copy of the License at
11. *
12. * http://www.apache.org/licenses/LICENSE-2.0
13. *
14. * Unless required by applicable law or agreed to in writing,
15. * software distributed under the License is distributed on an
16. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17. * KIND, either express or implied. See the License for the
18. * specific language governing permissions and limitations
19. * under the License.
20. *
21. * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
22. * @version //autogentag//
23. * @filesource
24. * @package Mail
25. */
27. /**
28. * Use this class to create a context to be passed to the walkParts() method from ezcMail.
29. *
30. * Example:
31. * <code>
32. * class App
33. * {
34. * public static function saveMailPart( $context, $mailPart )
35. * {
36. * // code to save the $mailPart object to disk
37. * }
38. * }
39. *
40. * // use the saveMailPart() function as a callback in walkParts()
41. * // where $mail is an ezcMail object.
42. * $context = new ezcMailPartWalkContext( array( 'App', 'saveMailPart' ) );
43. * $context->includeDigests = true; // if you want to go through the digests in the mail
44. * $mail->walkParts( $context, $mail );
45. * </code>
46. *
47. * @property array(string) $filter
48. * Used to restrict processing only to the specified mail part names.
49. * If empty or null, then ezcMailText, ezcMailFile and ezcMailRfc822Digest
50. * parts are processed. Usage e.g.: array( 'ezcMailFile' )
51. * @property callback $callbackFunction
52. * Name of a function or array( 'class_name', 'function_name' )
53. * @property bool $includeDigests
54. * If true then then ezcMailRfc822Digest parts are not processed by
55. * the callback function, instead the mail parts inside the digests will
56. * be available for processing.
57. * @property int $level
58. * The current level in the mail part walk (0 = first level).
59. *
60. * @package Mail
61. * @version //autogentag//
62. */
63. class ezcMailPartWalkContext
64. {
65. /**
66. * An array of mail parts (retrieved recursively from a mail object).
67. *
68. * @var array(ezcMailPart)
69. */
70. protected $parts = array();
72. /**
73. * Holds the properties of this class.
74. *
75. * @var array(string=>mixed)
76. */
77. private $properties = array();
79. /**
80. * Constructs a new ezcMailPartWalkContext object.
81. *
82. * The parameter $callbackFunction must be a function name as string or as
83. * array( 'class_name', 'function_name' ).
84. *
85. * @param callback $callbackFunction
86. */
87. public function __construct ( $callbackFunction )
88. {
89. $this->callbackFunction = $callbackFunction;
90. $this->level = 0;
91. $this->filter = array();
92. $this->includeDigests = false;
93. }
95. /**
96. * Sets the property $name to $value.
97. *
98. * @throws ezcBasePropertyNotFoundException
99. * if the property $name does not exist
100. * @throws ezcBaseValueException
101. * if $value is not appropiate for property $name
102. * @param string $name
103. * @param mixed $value
104. * @ignore
105. */
106. public function __set( $name, $value )
107. {
108. switch ( $name )
109. {
110. case 'level':
111. if ( ! is_numeric ( $value) || $value < 0 )
112. {
113. throw new ezcBaseValueException ( $name, $value, 'int >= 0' );
114. }
115. $this->properties[$name] = (int) $value;
116. break;
118. case 'includeDigests':
119. if ( ! is_bool ( $value ) )
120. {
121. throw new ezcBaseValueException ( $name, $value, 'bool' );
122. }
123. $this->properties[$name] = (bool) $value;
124. break;
126. case 'filter':
127. $this->properties[$name] = $value;
128. break;
130. case 'callbackFunction':
131. $this->properties[$name] = $value;
132. break;
134. default:
135. throw new ezcBasePropertyNotFoundException ( $name );
136. }
137. }
139. /**
140. * Returns the value of the property $name.
141. *
142. * @throws ezcBasePropertyNotFoundException
143. * if the property $name does not exist
144. * @param string $name
145. * @return mixed
146. * @ignore
147. */
148. public function __get( $name )
149. {
150. switch ( $name )
151. {
152. case 'level':
153. case 'filter':
154. case 'callbackFunction':
155. case 'includeDigests':
156. return $this->properties[$name];
158. default:
159. throw new ezcBasePropertyNotFoundException ( $name );
160. }
161. }
163. /**
164. * Returns true if the property $name is set, otherwise false.
165. *
166. * @param string $name
167. * @return bool
168. * @ignore
169. */
170. public function __isset( $name )
171. {
172. switch ( $name )
173. {
174. case 'level':
175. case 'filter':
176. case 'callbackFunction':
177. case 'includeDigests':
178. return isset( $this->properties[$name] );
180. default:
181. return false;
182. }
183. }
185. /**
186. * Appends a part to the list of mail parts.
187. *
188. * @param ezcMailPart $part
189. */
190. public function appendPart ( ezcMailPart $part )
191. {
192. $this-> parts [] = $part;
193. }
195. /**
196. * Returns the mail parts.
197. *
198. * @return array(ezcMailPart)
199. */
200. public function getParts ()
201. {
202. return $this-> parts ;
203. }
204. }
205. ?>

Documentation generated by phpDocumentor 1.4.3