2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * The PluginManager class is used alongside PluginObserver to implement
5 * the Observer Design Pattern.
9 if (! defined('PHPMYADMIN')) {
14 * This class implements the SplSubject interface
16 * @todo implement all methods
18 * @link http://php.net/manual/en/class.splsubject.php
21 class PluginManager
implements SplSubject
24 * Contains a list with all the plugins that attach to it
26 * @var type SplObjectStorage
31 * Contains information about the current plugin state
39 * Initializes $_storage with an empty SplObjectStorage
41 public function __construct()
43 $this->_storage
= new SplObjectStorage();
47 * Attaches an SplObserver so that it can be notified of updates
49 * @param SplObserver $observer The SplObserver to attach
53 function attach (SplObserver
$observer )
55 $this->_storage
->attach($observer);
59 * Detaches an observer from the subject to no longer notify it of updates
61 * @param SplObserver $observer The SplObserver to detach
65 function detach (SplObserver
$observer)
67 $this->_storage
->detach($observer);
71 * It is called after setStatus() was run by a certain plugin, and has
72 * the role of sending a notification to all of the plugins in $_storage,
73 * by calling the update() method for each of them.
82 /* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */
85 * Gets the list with all the plugins that attach to it
87 * @return type SplObjectStorage
89 public function getStorage()
91 return $this->_storage
;
95 * Setter for $_storage
97 * @param SplObjectStorage $_storage the list with all the plugins that
102 public function setStorage($_storage)
104 $this->_storage
= $_storage;
108 * Gets the information about the current plugin state
109 * It is called by all the plugins in $_storage in their update() method
113 public function getStatus()
115 return $this->_status
;
119 * Setter for $_status
120 * If a plugin changes its status, this has to be remembered in order to
121 * notify the rest of the plugins that they should update
123 * @param mixed $_status contains information about the current plugin state
127 public function setStatus($_status)
129 $this->_status
= $_status;