You are here

class HTTP_Request_Listener in Flickr API 5

Listener for HTTP_Request and HTTP_Response objects

This class implements the Observer part of a Subject-Observer design pattern.

@category HTTP @package HTTP_Request @author Alexey Borzov <avb@php.net> @version Release: 1.4.2

Hierarchy

Expanded class hierarchy of HTTP_Request_Listener

2 string references to 'HTTP_Request_Listener'
HTTP_Request::attach in phpFlickr/PEAR/HTTP/Request.php
Adds a Listener to the list of listeners that are notified of the object's events
HTTP_Request::detach in phpFlickr/PEAR/HTTP/Request.php
Removes a Listener from the list of listeners

File

phpFlickr/PEAR/HTTP/Request/Listener.php, line 56

View source
class HTTP_Request_Listener {

  /**
   * A listener's identifier
   * @var string
   */
  var $_id;

  /**
   * Constructor, sets the object's identifier
   *
   * @access public
   */
  function HTTP_Request_Listener() {
    $this->_id = md5(uniqid('http_request_', 1));
  }

  /**
   * Returns the listener's identifier
   *
   * @access public
   * @return string
   */
  function getId() {
    return $this->_id;
  }

  /**
   * This method is called when Listener is notified of an event
   *
   * @access   public
   * @param    object  an object the listener is attached to
   * @param    string  Event name
   * @param    mixed   Additional data
   * @abstract
   */
  function update(&$subject, $event, $data = null) {
    echo "Notified of event: '{$event}'\n";
    if (null !== $data) {
      echo "Additional data: ";
      var_dump($data);
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
HTTP_Request_Listener::$_id property A listener's identifier
HTTP_Request_Listener::getId function Returns the listener's identifier
HTTP_Request_Listener::HTTP_Request_Listener function Constructor, sets the object's identifier
HTTP_Request_Listener::update function This method is called when Listener is notified of an event