]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - extlib/HTTP/Request/Listener.php
Merge branch '0.7.x' into 0.8.x
[quix0rs-gnu-social.git] / extlib / HTTP / Request / Listener.php
1 <?php\r
2 /**\r
3  * Listener for HTTP_Request and HTTP_Response objects\r
4  *\r
5  * PHP versions 4 and 5\r
6  * \r
7  * LICENSE:\r
8  *\r
9  * Copyright (c) 2002-2007, Richard Heyes\r
10  * All rights reserved.\r
11  *\r
12  * Redistribution and use in source and binary forms, with or without\r
13  * modification, are permitted provided that the following conditions\r
14  * are met:\r
15  *\r
16  * o Redistributions of source code must retain the above copyright\r
17  *   notice, this list of conditions and the following disclaimer.\r
18  * o Redistributions in binary form must reproduce the above copyright\r
19  *   notice, this list of conditions and the following disclaimer in the\r
20  *   documentation and/or other materials provided with the distribution.\r
21  * o The names of the authors may not be used to endorse or promote\r
22  *   products derived from this software without specific prior written\r
23  *   permission.\r
24  *\r
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
26  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
27  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
28  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r
29  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
30  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
31  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
32  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
33  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
34  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r
35  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
36  *\r
37  * @category    HTTP\r
38  * @package     HTTP_Request\r
39  * @author      Alexey Borzov <avb@php.net>\r
40  * @copyright   2002-2007 Richard Heyes\r
41  * @license     http://opensource.org/licenses/bsd-license.php New BSD License\r
42  * @version     CVS: $Id: Listener.php,v 1.3 2007/05/18 10:33:31 avb Exp $\r
43  * @link        http://pear.php.net/package/HTTP_Request/ \r
44  */\r
45 \r
46 /**\r
47  * Listener for HTTP_Request and HTTP_Response objects\r
48  *\r
49  * This class implements the Observer part of a Subject-Observer\r
50  * design pattern.\r
51  *\r
52  * @category    HTTP\r
53  * @package     HTTP_Request\r
54  * @author      Alexey Borzov <avb@php.net>\r
55  * @version     Release: 1.4.4\r
56  */\r
57 class HTTP_Request_Listener \r
58 {\r
59    /**\r
60     * A listener's identifier\r
61     * @var string\r
62     */\r
63     var $_id;\r
64 \r
65    /**\r
66     * Constructor, sets the object's identifier\r
67     *\r
68     * @access public\r
69     */\r
70     function HTTP_Request_Listener()\r
71     {\r
72         $this->_id = md5(uniqid('http_request_', 1));\r
73     }\r
74 \r
75 \r
76    /**\r
77     * Returns the listener's identifier\r
78     *\r
79     * @access public\r
80     * @return string\r
81     */\r
82     function getId()\r
83     {\r
84         return $this->_id;\r
85     }\r
86 \r
87 \r
88    /**\r
89     * This method is called when Listener is notified of an event\r
90     *\r
91     * @access   public\r
92     * @param    object  an object the listener is attached to\r
93     * @param    string  Event name\r
94     * @param    mixed   Additional data\r
95     * @abstract\r
96     */\r
97     function update(&$subject, $event, $data = null)\r
98     {\r
99         echo "Notified of event: '$event'\n";\r
100         if (null !== $data) {\r
101             echo "Additional data: ";\r
102             var_dump($data);\r
103         }\r
104     }\r
105 }\r
106 ?>\r