\Phabstractic\PatternsPublisherTrait

Publisher Class - The basic minimal publisher functionality

This object keeps track of a state, thus implementing the state interface When that state changes it notifies all the observer objects its collected in its restricted set.

CHANGELOG

1.0 created Publisher - August 16th, 2013 2.0 Adapted to Primus2 - August 25th, 2015 3.0: changed from class to trait reformatted for inclusion in phabstractic - July 27th, 2016

Summary

Methods
Properties
Constants
attachObserver()
detachObserver()
unlinkFromObservers()
getObservers()
setStateObject()
getStateObject()
announce()
__debugInfo()
No public properties found
No constants found
constructPublisherObservers()
$publisherObservers
$publisherState
N/A
No private methods found
No private properties found
N/A

Properties

$publisherObservers

$publisherObservers : \Phabstractic\Patterns\Phabstractic\Data\Types\RestrictedSet

The observers (restricted set) that are listening to this publisher

Type

\Phabstractic\Patterns\Phabstractic\Data\Types\RestrictedSet

$publisherState

$publisherState : mixed

The state of the publisher, can be any object in this basic implementation

Type

mixed

Methods

attachObserver()

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

Parameters

\Phabstractic\Patterns\Phabstractic\Patterns\Resource\ObserverInterface $observer

detachObserver()

detachObserver(\Phabstractic\Patterns\Phabstractic\Patterns\Resource\ObserverInterface  $observer) 

Detach a listener/observer from the publisher

Removes the observer from the restricted set

Parameters

\Phabstractic\Patterns\Phabstractic\Patterns\Resource\ObserverInterface $observer

unlinkFromObservers()

unlinkFromObservers() 

Unlink this publisher from all observers

getObservers()

getObservers() : array

Retrieve an ARRAY of the observing objects for this publisher

Returns

array

setStateObject()

setStateObject(\Phabstractic\Patterns\Phabstractic\Pattern\Resource\StateInterface  $state) 

Set the publishers state, this notifies the observers

Parameters

\Phabstractic\Patterns\Phabstractic\Pattern\Resource\StateInterface $state

getStateObject()

getStateObject() : \Phabstractic\Patterns\Phabstractic\Pattern\Resource\StateInterface

Retrieve the state object, whatever it may contain

Returns

\Phabstractic\Patterns\Phabstractic\Pattern\Resource\StateInterface

announce()

announce() 

Notify all the observers in the set of the state change, or otherwise

__debugInfo()

__debugInfo() 

Debug Info (var_dump)

Display debug info

Requires PHP 5.6+

constructPublisherObservers()

constructPublisherObservers() 

Make sure $this->publisherObservers has been constructed