\Phabstractic\Patterns\ResourcePublisherInterface

Publisher Interface - Identifies Many Different Objects As Notifiable

Any object that implements the publisher interface is capable of registering listeners and announcing a change in their state. Announce can theoretically be called at any given time during the function of the publisher

CHANGELOG

1.0: created PublisherInterface - August 16th, 2013 2.0: refactored file to fit Primus - April 2nd, 2015 3.0: de-coupled stateinterface as ambiguous reformatted for inclusion in phabstractic - July 26th, 2016

Summary

Methods
Constants
attachObserver()
detachObserver()
unlinkFromObservers()
getObservers()
announce()
getStateObject()
setStateObject()
No constants found
No protected methods found
N/A
No private methods found
N/A

Methods

attachObserver()

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

Attach An Observer

Attach an observer to this publisher so that it can be notified of state changes

Parameters

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

detachObserver()

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

Detach An Observer

Detach an observer from this publisher so it is no longer modified of state changes

Parameters

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

unlinkFromObservers()

unlinkFromObservers() 

Detach this publisher from all observers

getObservers()

getObservers() : array

Get an array of observer objects

Returns

array

announce()

announce() 

Notify Observers

Announce information to all the attached observers

getStateObject()

getStateObject() : \Phabstractic\Patterns\Resource\Phabstractic\patterns\resource\StateInterface

Retrieve A State Object

Returns

\Phabstractic\Patterns\Resource\Phabstractic\patterns\resource\StateInterface

setStateObject()

setStateObject(\Phabstractic\Patterns\Resource\Phabstractic\patterns\resource\StateInterface  $state) 

Set State Object

In an 'event' publisher/observer ecosystem, such as asherwunk/phabstractic/-/event:

Replaces the current state object with a new state object. In order for the observer/publisher pattern to work it is recommended that this function notifies all observers of the host object.

Parameters

\Phabstractic\Patterns\Resource\Phabstractic\patterns\resource\StateInterface $state

The State Object