[ Index ]
 

Code source de LifeType 1.2.4

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/class/object/ -> observer.class.php (source)

   1  <?php
   2  
   3      
   4  
   5      /**
   6       * \ingroup Core
   7       * 
   8       * Implementation of the Observer pattern. Copied/Inspired ;) from
   9       * http://www.phppatterns.com/index.php/article/articleview/27/1/1/.
  10       * Base Observer class     
  11       */
  12      class Observer {
  13  
  14          /**
  15           * @private
  16           * $subject a child of class Observable that we're observing
  17           */
  18          var $subject;
  19  
  20          /**
  21           * Constructs the Observer
  22           * @param $subject the object to observe
  23           */
  24          function Observer (& $subject)
  25          {
  26              $this->subject=& $subject;
  27  
  28              // Register this object so subject can notify it
  29              $subject->addObserver($this);
  30          }
  31  
  32          /**
  33           * Abstract function implemented by children to repond to
  34           * to changes in Observable subject
  35           * @return void
  36           */
  37          function update() {
  38              //trigger_error ('Update not implemented');
  39              throw( new Exception( "Observer class: Update method must be implemented by observer classes." ));
  40          }
  41      }
  42  ?>


Généré le : Mon Nov 26 21:04:15 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics