Source for file event.php

Documentation is available at event.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Platform
  4.  * @subpackage  Event
  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.  * JEvent Class
  14.  *
  15.  * @package     Joomla.Platform
  16.  * @subpackage  Event
  17.  * @since       11.1
  18.  */
  19. abstract class JEvent extends JObject
  20. {
  21.     /**
  22.      * Event object to observe.
  23.      *
  24.      * @var    object 
  25.      * @since  11.3
  26.      */
  27.     protected $_subject = null;
  28.  
  29.     /**
  30.      * Constructor
  31.      *
  32.      * @param   object  &$subject  The object to observe.
  33.      *
  34.      * @since   11.3
  35.      */
  36.     public function __construct(&$subject)
  37.     {
  38.         // Register the observer ($this) so we can be notified
  39.         $subject->attach($this);
  40.  
  41.         // Set the subject to observe
  42.         $this->_subject = &$subject;
  43.     }
  44.  
  45.     /**
  46.      * Method to trigger events.
  47.      * The method first generates the even from the argument array. Then it unsets the argument
  48.      * since the argument has no bearing on the event handler.
  49.      * If the method exists it is called and returns its return value. If it does not exist it
  50.      * returns null.
  51.      *
  52.      * @param   array  &$args  Arguments
  53.      *
  54.      * @return  mixed  Routine return value
  55.      *
  56.      * @since   11.1
  57.      */
  58.     public function update(&$args)
  59.     {
  60.         // First let's get the event from the argument array.  Next we will unset the
  61.         // event argument as it has no bearing on the method to handle the event.
  62.         $event $args['event'];
  63.         unset($args['event']);
  64.  
  65.         /*
  66.          * If the method to handle an event exists, call it and return its return
  67.          * value.  If it does not exist, return null.
  68.          */
  69.         if (method_exists($this$event))
  70.         {
  71.             return call_user_func_array(array($this$event)$args);
  72.         }
  73.         else
  74.         {
  75.             return null;
  76.         }
  77.     }
  78. }

Documentation generated on Tue, 19 Nov 2013 15:02:39 +0100 by phpDocumentor 1.4.3