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.  * Observer pattern interface for Joomla
  14.  *
  15.  * A class that wants to observe another class must:
  16.  *
  17.  * 1) Add: implements JObserverInterface
  18.  *    to its class
  19.  *
  20.  * 2) Implement a constructor, that can look like this:
  21.  *     public function __construct(JObservableInterface $observableObject)
  22.  *     {
  23.  *         $observableObject->attachObserver($this);
  24.  *      $this->observableObject = $observableObject;
  25.  *     }
  26.  *
  27.  * 3) and must implement the instanciator function createObserver() below, e.g. as follows:
  28.  *     public static function createObserver(JObservableInterface $observableObject, $params = array())
  29.  *     {
  30.  *         $observer = new self($observableObject);
  31.  *      $observer->... = $params['...']; ...
  32.  *         return $observer;
  33.  *     }
  34.  *
  35.  * 4) Then add functions corresponding to the events to be observed,
  36.  *    E.g. to respond to event: $this->_observers->update('onBeforeLoad', array($keys, $reset));
  37.  *    following function is needed in the obser:
  38.  *  public function onBeforeLoad($keys, $reset) { ... }
  39.  *
  40.  * 5) Finally, the binding is made outside the observable and observer classes, using:
  41.  * JObserverMapper::addObserverClassToClass('ObserverClassname', 'ObservableClassname', array('paramName' => 'paramValue'));
  42.  * where the last array will be provided to the observer instanciator function createObserver.
  43.  *
  44.  * @package     Joomla.Platform
  45.  * @subpackage  Observer
  46.  * @link        http://docs.joomla.org/JObserverInterface
  47.  * @since       3.1.2
  48.  */
  49. {
  50.     /**
  51.      * Creates the associated observer instance and attaches it to the $observableObject
  52.      *
  53.      * @param   JObservableInterface  $observableObject  The observable subject object
  54.      * @param   array                 $params            Params for this observer
  55.      *
  56.      * @return  JObserverInterface 
  57.      *
  58.      * @since   3.1.2
  59.      */
  60.     public static function createObserver(JObservableInterface $observableObject$params array());
  61. }

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