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