Perforce Chronicle 2012.2/486814
API Documentation

P4Cms_PubSub_Provider Class Reference

Extend Phly Publish Subscribe facility. More...

List of all members.

Public Member Functions

 filter ($topic, $args=null)
 Filter a value.
 publish ($topic, $args=null)
 Publish to all handlers for a given topic.

Detailed Description

Extend Phly Publish Subscribe facility.

Copyright:
2011-2012 Perforce Software. All rights reserved
License:
Please see LICENSE.txt in top-level folder of this distribution.
Version:
2012.2/486814

Member Function Documentation

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.

Parameters:
string$topicTopic to apply filter to
mixed$argsAll arguments besides the topic are passed as arguments to the handler
Returns:
mixed
    {
        $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.

Parameters:
string$topicTopic to publish handlers for
mixed$argsAll arguments besides the topic are passed as arguments to the handler
Returns:
array all of the return values from all subscribers.
    {
        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;
    }

The documentation for this class was generated from the following file: