PageRenderTime 26ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/bundled-libs/HTTP/Request/Listener.php

http://github.com/s9y/Serendipity
PHP | 96 lines | 22 code | 6 blank | 68 comment | 1 complexity | d980b02bbae806dfb5eb06f94d4b94ca MD5 | raw file
Possible License(s): BSD-3-Clause, LGPL-3.0, LGPL-2.1, MPL-2.0-no-copyleft-exception, Apache-2.0
  1. <?php
  2. // +-----------------------------------------------------------------------+
  3. // | Copyright (c) 2002-2003, Richard Heyes |
  4. // | All rights reserved. |
  5. // | |
  6. // | Redistribution and use in source and binary forms, with or without |
  7. // | modification, are permitted provided that the following conditions |
  8. // | are met: |
  9. // | |
  10. // | o Redistributions of source code must retain the above copyright |
  11. // | notice, this list of conditions and the following disclaimer. |
  12. // | o Redistributions in binary form must reproduce the above copyright |
  13. // | notice, this list of conditions and the following disclaimer in the |
  14. // | documentation and/or other materials provided with the distribution.|
  15. // | o The names of the authors may not be used to endorse or promote |
  16. // | products derived from this software without specific prior written |
  17. // | permission. |
  18. // | |
  19. // | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
  20. // | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
  21. // | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
  22. // | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
  23. // | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
  24. // | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
  25. // | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
  26. // | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
  27. // | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
  28. // | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
  29. // | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
  30. // | |
  31. // +-----------------------------------------------------------------------+
  32. // | Author: Alexey Borzov <avb@php.net> |
  33. // +-----------------------------------------------------------------------+
  34. //
  35. // $Id: Listener.php,v 1.2 2003/10/26 10:28:29 avb Exp $
  36. //
  37. /**
  38. * This class implements the Observer part of a Subject-Observer
  39. * design pattern. It listens to the events sent by a
  40. * HTTP_Request or HTTP_Response instance.
  41. *
  42. * @package HTTP_Request
  43. * @author Alexey Borzov <avb@php.net>
  44. * @version $Revision: 1.2 $
  45. */
  46. class HTTP_Request_Listener
  47. {
  48. /**
  49. * A listener's identifier
  50. * @var string
  51. */
  52. var $_id;
  53. /**
  54. * Constructor, sets the object's identifier
  55. *
  56. * @access public
  57. */
  58. function HTTP_Request_Listener()
  59. {
  60. $this->_id = md5(uniqid('http_request_', 1));
  61. }
  62. /**
  63. * Returns the listener's identifier
  64. *
  65. * @access public
  66. * @return string
  67. */
  68. function getId()
  69. {
  70. return $this->_id;
  71. }
  72. /**
  73. * This method is called when Listener is notified of an event
  74. *
  75. * @access public
  76. * @param object an object the listener is attached to
  77. * @param string Event name
  78. * @param mixed Additional data
  79. * @abstract
  80. */
  81. function update(&$subject, $event, $data = null)
  82. {
  83. echo "Notified of event: '$event'\n";
  84. if (null !== $data) {
  85. echo "Additional data: ";
  86. var_dump($data);
  87. }
  88. }
  89. }
  90. ?>