FOF30\Event\Observer::__construct PHP Method

__construct() public method

Creates the observer and attaches it to the observable subject object
public __construct ( FOF30\Event\Observable &$subject )
$subject FOF30\Event\Observable The observable object to attach the observer to
    function __construct(Observable &$subject)
    {
        // Attach this observer to the subject
        $subject->attach($this);
        // Store a reference to the subject object
        $this->subject = $subject;
    }

Usage Example

Example #1
0
 /**
  * Assigns callback functions to the class, the $methods array should be an associative one, where
  * the keys are the method names, while the values are the closure functions, e.g.
  *
  * array(
  *    'onBeforeMove' => function(){ return 'Foobar'; }
  * )
  *
  * @param Observable $subject
  * @param array $methods
  */
 public function __construct(Observable &$subject, array $methods = array())
 {
     parent::__construct($subject);
     foreach ($methods as $method => $function) {
         $this->methods[$method] = $function;
     }
 }
All Usage Examples Of FOF30\Event\Observer::__construct