$publisherObservers
$publisherObservers : \Phabstractic\Patterns\Phabstractic\Data\Types\RestrictedSet
The observers (restricted set) that are listening to this publisher
The Aggregator Class
This class puts a whole bunch of publishers under one roof.
They each vie to change the state (causing an event to fire) of the aggregate with their own states, but they are filtered by a built in filter (usually a custom filter)
CHANGELOG
1.0 Created Aggregator - August 16th, 2013 2.0 Integrated into Primus 2 Changed Filter to FilterInterface - October 14th, 2015 3.0: updated to use observertrait and publishertrait reformatted for inclusion in phabstractic - July 31st, 2016
$observedSubjects : \Phabstractic\Patterns\Phabstractic\Patterns\Resource\PublisherInterface
The subjects that this observer is listening to
For an observer that listens to multiple publishers with some added functionality see Phabstractic\Event\Aggregator
attachObserver(\Phabstractic\Patterns\Phabstractic\Patterns\Resource\ObserverInterface $observer)
Attach an observer object to this publisher
This places an observer into the restricted set, as well as establishes this publisher as the observers subject
\Phabstractic\Patterns\Phabstractic\Patterns\Resource\ObserverInterface | $observer |
setStateObject(\Phabstractic\Event\Phabstractic\Patterns\Resource\StateInterface $state) : boolean
Set the state of the aggregator, causes announce
We run the state through the filter, if present, and if it makes it we change the state and announce it to all our listeners
\Phabstractic\Event\Phabstractic\Patterns\Resource\StateInterface | $state | The State Object |
True if event is handled
detachPublisher(\Phabstractic\Patterns\Resource\PublisherInterface $publisher)
This detaches the observer from its subject
Reciprocal methods exist in the publisher
\Phabstractic\Patterns\Resource\PublisherInterface | $publisher |
attachPublisher(\Phabstractic\Patterns\Resource\PublisherInterface $publisher)
Attach this observer to a new publisher
This also acts like a 'set' function, and null is an acceptable value to be passed
\Phabstractic\Patterns\Resource\PublisherInterface | $publisher |
notifyObserver(\Phabstractic\Event\Phabstractic\Patterns\Resource\PublisherInterface $publisher, \Phabstractic\Event\Phabstractic\Patterns\Resource\StateInterface $state) : boolean
Get notified of a state change from one of our publishers
It accepts any capable publisher, and any capable state change information.
This for example is used in the universal event system, where state is the most recent event
\Phabstractic\Event\Phabstractic\Patterns\Resource\PublisherInterface | $publisher | |
\Phabstractic\Event\Phabstractic\Patterns\Resource\StateInterface | $state | Maybe new state, (abstract event) |
true if handled (is AbstractEvent)
__construct(\Phabstractic\Event\Phabstractic\Event\Filter $filter = null, array $publishers = array())
The Aggregator Class Constructor
This class is an observer and a publisher We take in all our publishers in an array and create another careful set for our observers too. We can also specify the head filter here too. (Usually a custom filter for this class)
\Phabstractic\Event\Phabstractic\Event\Filter | $filter | The head filter |
array | $publishers | The publishers we're listening to and aggregating |