Public Member Functions | |
__construct () | |
getAllEvents () | |
getGlobalObservers () | |
getEventByName ($eventName) | |
addEvent (Varien_Event $event) | |
addObserver (Varien_Event_Observer $observer) | |
dispatch ($eventName, array $data=array()) | |
Protected Attributes | |
$_events | |
$_observers |
Definition at line 35 of file Collection.php.
__construct | ( | ) |
Initializes global observers collection
Definition at line 57 of file Collection.php.
00058 { 00059 $this->_events = array(); 00060 $this->_globalObservers = new Varien_Event_Observer_Collection(); 00061 }
addEvent | ( | Varien_Event $ | event | ) |
Register an event for this collection
Varien_Event | $event |
Definition at line 105 of file Collection.php.
addObserver | ( | Varien_Event_Observer $ | observer | ) |
Register an observer
If observer has event_name property it will be regitered for this specific event. If not it will be registered as global observer
Varien_Event_Observer | $observer |
Definition at line 120 of file Collection.php.
00121 { 00122 $eventName = $observer->getEventName(); 00123 if ($eventName) { 00124 $this->getEventByName($eventName)->addObserver($observer); 00125 } else { 00126 $this->getGlobalObservers()->addObserver($observer); 00127 } 00128 return $this; 00129 }
Dispatch event name with optional data
Will dispatch specific event and will try all global observers
string | $eventName | |
array | $data |
Definition at line 140 of file Collection.php.
00141 { 00142 $event = $this->getEventByName($eventName); 00143 $event->addData($data)->dispatch(); 00144 $this->getGlobalObservers()->dispatch($event); 00145 return $this; 00146 }
getAllEvents | ( | ) |
Returns all registered events in collection
Definition at line 68 of file Collection.php.
getEventByName | ( | $ | eventName | ) |
Returns event by its name
If event doesn't exist creates new one and returns it
string | $eventName |
Definition at line 91 of file Collection.php.
00092 { 00093 if (!isset($this->_events[$eventName])) { 00094 $this->addEvent(new Varien_Event(array('name'=>$eventName))); 00095 } 00096 return $this->_events[$eventName]; 00097 }
getGlobalObservers | ( | ) |
Returns all registered global observers for the collection of events
Definition at line 78 of file Collection.php.
$_events [protected] |
Definition at line 42 of file Collection.php.
$_observers [protected] |
Definition at line 51 of file Collection.php.