Perforce Chronicle 2012.2/486814
API Documentation
|
Extend Phly Publish Subscribe facility. More...
Public Member Functions | |
filter ($topic, $args=null) | |
Filter a value. | |
publish ($topic, $args=null) | |
Publish to all handlers for a given topic. |
Extend Phly Publish Subscribe facility.
P4Cms_PubSub_Provider::filter | ( | $ | topic, |
$ | args = null |
||
) |
Filter a value.
Extends parent to return original value when there are no topics.
Notifies subscribers to the topic and passes the single value provided as an argument. Each subsequent subscriber is passed the return value of the previous subscriber, and the value of the last subscriber is returned.
string | $topic | Topic to apply filter to |
mixed | $args | All arguments besides the topic are passed as arguments to the handler |
{ $args = func_get_args(); array_shift($args); if (empty($this->_topics[$topic])) { return $args[0]; } foreach ($this->_topics[$topic] as $handle) { $args[0] = $handle->call($args); } return $args[0]; }
P4Cms_PubSub_Provider::publish | ( | $ | topic, |
$ | args = null |
||
) |
Publish to all handlers for a given topic.
Extends parent implementation to collect all return values.
string | $topic | Topic to publish handlers for |
mixed | $args | All arguments besides the topic are passed as arguments to the handler |
{ if (empty($this->_topics[$topic])) { return array(); } $return = array(); $args = func_get_args(); array_shift($args); foreach ($this->_topics[$topic] as $handle) { $return[] = $handle->call($args); } return $return; }