Support Joomla!

Packages

Package: Joomla-Framework

License

Content on this site is copyright © 2005 - 2008 Open Source Matters Inc and can be used in accordance with the Joomla! Electronic Documentation License. Some parts of this website may be subject to other licenses.
Source code for file /joomla/base/observer.php

Documentation is available at observer.php

  1. <?php
  2. /**
  3. @version        $Id:observer.php 6961 2007-03-15 16:06:53Z tcp $
  4. @package        Joomla.Framework
  5. @subpackage    Base
  6. @copyright    Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
  7. @license        GNU/GPL, see LICENSE.php
  8. *  Joomla! is free software. This version may have been modified pursuant
  9. *  to the GNU General Public License, and as distributed it includes or
  10. *  is derivative of works licensed under the GNU General Public License or
  11. *  other free or open source software licenses.
  12. *  See COPYRIGHT.php for copyright notices and details.
  13. */
  14.  
  15. // Check to ensure this file is within the rest of the framework
  16. defined('JPATH_BASE'or die();
  17.  
  18. /**
  19.  * Abstract observer class to implement the observer design pattern
  20.  *
  21.  * @abstract
  22.  * @subpackage    Base
  23.  * @since        1.5
  24.  */
  25. class JObserver extends JObject
  26. {
  27.  
  28.     /**
  29.      * Event object to observe
  30.      *
  31.      * @access private
  32.      * @var object 
  33.      */
  34.     var $_subject null;
  35.  
  36.     /**
  37.      * Constructor
  38.      */
  39.     function __construct($subject)
  40.     {
  41.         // Register the observer ($this) so we can be notified
  42.         $subject->attach($this);
  43.  
  44.         // Set the subject to observe
  45.         $this->_subject $subject;
  46.     }
  47.  
  48.     /**
  49.      * Method to update the state of observable objects
  50.      *
  51.      * @abstract Implement in child classes
  52.      * @access public
  53.      * @return mixed 
  54.      */
  55.     function update({
  56.         return JError::raiseError('9''JObserver::update: Method not implemented''This method should be implemented in a child class');
  57.     }
  58. }

Documentation generated on Mon, 22 Sep 2008 12:11:17 +0100 by phpDocumentor 1.3.1