P4Cms_PubSub is a subclass of Phly_PubSub which makes use of our own pubsub provider, to make subscription results consistent.
More...
List of all members.
Public Member Functions |
| filter ($topic, $args) |
| Filter a value.
|
| publishUntil ($callback, $topic, $args=null) |
| Notify subscribers until return value of one causes a callback to evaluate to true.
|
Static Public Member Functions |
static | clearHandles ($topic) |
| Clear all handlers for a given topic.
|
static | getInstance () |
| Retrieve PubSub provider instance.
|
static | getSubscribedHandles ($topic) |
| Retrieve all handlers for a given topic.
|
static | getTopics () |
| Retrieve all registered topics.
|
static | publish ($topic, $args=null) |
| Publish to all handlers for a given topic.
|
static | setInstance (P4Cms_PubSub_Provider $provider) |
| Set PubSub provider instance.
|
static | subscribe ($topic, $context, $handler=null) |
| Subscribe to a topic.
|
static | unsubscribe (Phly_PubSub_Handle $handle) |
| Unsubscribe a handler from a topic.
|
Public Attributes |
const | TOPIC_DELIMITER = '.' |
Static Protected Attributes |
static | $_instance |
Detailed Description
P4Cms_PubSub is a subclass of Phly_PubSub which makes use of our own pubsub provider, to make subscription results consistent.
- 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
static P4Cms_PubSub::clearHandles |
( |
$ |
topic | ) |
[static] |
Clear all handlers for a given topic.
- Parameters:
-
string | $topic | Topic to clear handlers for |
- Returns:
- void
P4Cms_PubSub::filter |
( |
$ |
topic, |
|
|
$ |
args |
|
) |
| |
Filter a value.
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 | $topic | Topic to apply filter to |
mixed | $args | All arguments besides the topic are passed as arguments to the handler |
- Returns:
- mixed
{
return call_user_func_array(
array(self::getInstance(), 'filter'),
func_get_args()
);
}
static P4Cms_PubSub::getInstance |
( |
| ) |
[static] |
static P4Cms_PubSub::getSubscribedHandles |
( |
$ |
topic | ) |
[static] |
Retrieve all handlers for a given topic.
- Parameters:
-
string | $topic | Topic to get handlers for |
- Returns:
- array Array of Phly_PubSub_Handle objects
static P4Cms_PubSub::getTopics |
( |
| ) |
[static] |
Retrieve all registered topics.
- Returns:
- array
static P4Cms_PubSub::publish |
( |
$ |
topic, |
|
|
$ |
args = null |
|
) |
| [static] |
Publish to all handlers for a given topic.
- Parameters:
-
string | $topic | Topic to publish |
mixed | $args | All arguments besides the topic are passed as arguments to the handler |
- Returns:
- void
{
return call_user_func_array(
array(self::getInstance(), 'publish'),
func_get_args()
);
}
P4Cms_PubSub::publishUntil |
( |
$ |
callback, |
|
|
$ |
topic, |
|
|
$ |
args = null |
|
) |
| |
Notify subscribers until return value of one causes a callback to evaluate to true.
Publishes subscribers until the provided callback evaluates the return value of one as true, or until all subscribers have been executed.
- Parameters:
-
Callable | $callback | Callback function to test when notifications should cease |
string | $topic | Topic to publish |
mixed | $args | All arguments besides the topic are passed as arguments to the handler |
- Returns:
- mixed
- Exceptions:
-
Phly_PubSub_InvalidCallbackException | if invalid callback provided |
{
return call_user_func_array(
array(self::getInstance(), 'publishUntil'),
func_get_args()
);
}
Set PubSub provider instance.
- Parameters:
-
- Returns:
- void
{
self::$_instance = $provider;
}
static P4Cms_PubSub::subscribe |
( |
$ |
topic, |
|
|
$ |
context, |
|
|
$ |
handler = null |
|
) |
| [static] |
Subscribe to a topic.
- Parameters:
-
string | $topic | Topic to subscribe to |
string | object | $context | Function name, class name, or object instance |
null | string | $handler | If $context is a class or object, the name of the method to call |
- Returns:
- Phly_PubSub_Handle Pub-Sub handle (to allow later unsubscribe)
{
$provider = self::getInstance();
return $provider->subscribe($topic, $context, $handler);
}
static P4Cms_PubSub::unsubscribe |
( |
Phly_PubSub_Handle $ |
handle | ) |
[static] |
Unsubscribe a handler from a topic.
- Parameters:
-
Phly_PubSub_Handle | $handle | Handler to unsubcribe from a topic |
- Returns:
- bool Returns true if topic and handle found, and unsubscribed; returns false if either topic or handle not found.
Member Data Documentation
P4Cms_PubSub::$_instance [static, protected] |
The documentation for this class was generated from the following file: