Source for file interface.php

Documentation is available at interface.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Platform
  4.  * @subpackage  Observer
  5.  *
  6.  * @copyright   Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
  7.  * @license     GNU General Public License version 2 or later; see LICENSE
  8.  */
  9.  
  10. defined('JPATH_PLATFORM'or die;
  11.  
  12. /**
  13.  * Observable Subject pattern interface for Joomla
  14.  *
  15.  * To make a class and its inheriting classes observable:
  16.  * 1) add: implements JObservableInterface
  17.  *    to its class
  18.  *
  19.  * 2) at the end of the constructor, add:
  20.  * // Create observer updater and attaches all observers interested by $this class:
  21.  * $this->_observers = new JObserverUpdater($this);
  22.  * JObserverMapper::attachAllObservers($this);
  23.  *
  24.  * 3) add the function attachObserver below to your class to add observers using the JObserverUpdater class:
  25.  *     public function attachObserver(JObserverInterface $observer)
  26.  *     {
  27.  *         $this->_observers->attachObserver($observer);
  28.  *     }
  29.  *
  30.  * 4) in the methods that need to be observed, add, e.g. (name of event, params of event):
  31.  *         $this->_observers->update('onBeforeLoad', array($keys, $reset));
  32.  *
  33.  * @package     Joomla.Platform
  34.  * @subpackage  Observer
  35.  * @link        http://docs.joomla.org/JObservableInterface
  36.  * @since       3.1.2
  37.  */
  38. {
  39.     /**
  40.      * Adds an observer to this JObservableInterface instance.
  41.      * Ideally, this method should be called fron the constructor of JObserverInterface
  42.      * which should be instanciated by JObserverMapper.
  43.      * The implementation of this function can use JObserverUpdater
  44.      *
  45.      * @param   JObserverInterface  $observer  The observer to attach to $this observable subject
  46.      *
  47.      * @return  void 
  48.      *
  49.      * @since   3.1.2
  50.      */
  51.     public function attachObserver(JObserverInterface $observer);
  52. }

Documentation generated on Tue, 19 Nov 2013 15:05:49 +0100 by phpDocumentor 1.4.3