Joomla Platform  13.1
Documentation des API du framework Joomla Platform
 Tout Classes Espaces de nommage Fichiers Fonctions Variables Pages
interface.php
Aller à la documentation de ce fichier.
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  * Observable Subject pattern interface for Joomla
14  *
15  * To make a class and its inheriting classes observable:
16  * 1) add: implements JObservableInterface
17  * to its class
18  *
19  * 2) at the end of the constructor, add:
20  * // Create observer updater and attaches all observers interested by $this class:
21  * $this->_observers = new JObserverUpdater($this);
22  * JObserverMapper::attachAllObservers($this);
23  *
24  * 3) add the function attachObserver below to your class to add observers using the JObserverUpdater class:
25  * public function attachObserver(JObserverInterface $observer)
26  * {
27  * $this->_observers->attachObserver($observer);
28  * }
29  *
30  * 4) in the methods that need to be observed, add, e.g. (name of event, params of event):
31  * $this->_observers->update('onBeforeLoad', array($keys, $reset));
32  *
33  * @package Joomla.Platform
34  * @subpackage Observer
35  * @link http://docs.joomla.org/JObservableInterface
36  * @since 3.1.2
37  */
39 {
40  /**
41  * Adds an observer to this JObservableInterface instance.
42  * Ideally, this method should be called fron the constructor of JObserverInterface
43  * which should be instanciated by JObserverMapper.
44  * The implementation of this function can use JObserverUpdater
45  *
46  * @param JObserverInterface $observer The observer to attach to $this observable subject
47  *
48  * @return void
49  *
50  * @since 3.1.2
51  */
52  public function attachObserver(JObserverInterface $observer);
53 }