\Phabstractic\EventGenericEvent

Generic Event Class - Provides a simple implementation of AbstractEvent

This class provides the member methods necessary to instantiate or inherit an AbstractEvent.

It is recommended that all events inherit from the generic event class to be used in the universal event system

CHANGELOG

1.0 Created Generic Event - August 16th, 2013 2.0 Integrated Generic Event into Primus2 - September 13th, 2015 3.0: reformatted for inclusion in phabstractic - July 29th., 2016

Summary

Methods
Properties
Constants
__construct()
getState()
setState()
setStateWithArray()
setStateWithEvent()
getIdentifier()
getCategories()
getCategoriesSet()
addCategory()
addCategories()
setCategories()
removeCategory()
isCategory()
getTags()
getTagsSet()
addTag()
addTags()
setTags()
removeTag()
isTag()
getTarget()
getTargetReference()
setTarget()
setTargetReference()
getData()
getDataReference()
setData()
setDataReference()
getFunction()
getClass()
getNamespace()
stop()
proceed()
isStopped()
force()
subdue()
isUnstoppable()
__debugInfo()
No public properties found
No constants found
getNewIdentity()
setIdentifier()
$identityCounter
$identityPrefix
$identifier
$tags
$categories
$target
$data
$class
$function
$namespace
$stop
$force
N/A
No private methods found
No private properties found
N/A

Properties

$identityCounter

$identityCounter : mixed

The Global Identity Generator Marker

When the identity is polled, this marker is 'advanced'. It's static to the class, in that way it's unique for each one.

Type

mixed — The current identity

$identityPrefix

$identityPrefix : mixed

The Identity Marker Prefix

Specific to a given class, this is placed with/in front of the identity (context) This is a bit strange to understand why it's not static, but imagine a finer grain of control

Type

mixed — The class's context/marker prefix

$identifier

$identifier : mixed

The event identifier

This is implementation specific

Type

mixed

$tags

$tags : \Phabstractic\Event\Resource\Falcraft\Data\Types\Set

The tags associated with this event

Type

\Phabstractic\Event\Resource\Falcraft\Data\Types\Set

$categories

$categories : \Phabstractic\Event\Resource\Falcraft\Data\Types\Set

The categories associated with this event

Type

\Phabstractic\Event\Resource\Falcraft\Data\Types\Set

$target

$target : mixed

The publishing object of the event

This doesn't necessarily always equal the object that generated the event. Kooky.

Type

mixed

$data

$data : mixed

Any data associated with the event

Type

mixed

$class

$class : string

The class that generated the event

This should ALWAYS equal the classname (if we're in a class) that generated the event.

Type

string

$function

$function : string

The function that generated the event

This should ALWAYS equal the function name that generated the event.

Type

string

$namespace

$namespace : string

The namespace generating the event

This should ALWAYS reflect the namespace of the class or function that generated the event.

Type

string

$stop

$stop : boolean

Has the event stopped propagation?

This has to be checked by handlers themselves

Type

boolean

$force

$force : boolean

Is this event currently unstoppable?

This has to be checked by conduits and handlers themselves

Type

boolean

Methods

__construct()

__construct(object  $target, string  $function, string  $class, string  $namespace, mixed  $data = null, array  $tags = array(), array  $cats = array()) 

The Generic Event Constructor

This is implements an event, setting all the necessary fields

Parameters

object $target

The target of the event

string $function

The function/method generating the event

string $class

The class name generating the event if applicable

string $namespace

The namespace of the generating point

mixed $data

Any data associated with the event

array $tags

An array of strings associating the event with a set of tags

array $cats

An array of strings associating the event with a set of categories

getState()

getState() : array

This returns an array containing the object state

This converts the event state to an array, tags and categories are set up as sub-arrays, as well as the available object members

Returns

array

setState()

setState(  $state) 

State Interface Status Set

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

Replaces the current state object's data. In order for the observer/publisher pattern to work it is recommended that the caller of this function notifies all observers of the host object.

Parameters

$state

setStateWithArray()

setStateWithArray(array  $state, boolean  $morph = true) 

This sets or morphs an event with new information

If morph is set, the event doesn't clear it's information, and instead overwrites whats already there.

$state must include identifier

Parameters

array $state
boolean $morph

Whether we should replace or overwrite the object state

setStateWithEvent()

setStateWithEvent(\Phabstractic\Event\Resource\EventInterface  $state, boolean  $morph = true) 

This sets or morphs an event with new information

If morph is set, the event doesn't clear it's information, and instead overwrites whats already there.

Parameters

\Phabstractic\Event\Resource\EventInterface $state
boolean $morph

Whether we should replace or overwrite the object state

getIdentifier()

getIdentifier() : mixed

Retrieve the event identifier

Returns

mixed

getCategories()

getCategories() : array

Return the categories of the event

NOTE: This returns an array

Returns

array

getCategoriesSet()

getCategoriesSet() : \Phabstractic\Event\Resource\Phabstractic\Data\Types\Set

Return the categories of the event

NOTE: This returns a set object

Returns

\Phabstractic\Event\Resource\Phabstractic\Data\Types\Set

addCategory()

addCategory(  $category) 

Add a category to the event

Parameters

$category

addCategories()

addCategories(array  $categories) 

Add cateogires to the event

Parameters

array $categories

setCategories()

setCategories(array  $categories) 

Set a bunch of categories at once

Parameters

array $categories

removeCategory()

removeCategory(  $category) 

Remove a category from the event

Parameters

$category

isCategory()

isCategory(  $category) : boolean

Does this event have a particular category?

Parameters

$category

Returns

boolean

getTags()

getTags() : array

Get the tags associated with this event

NOTE: This returns an array

Returns

array

getTagsSet()

getTagsSet() : \Phabstractic\Event\Resource\Phabstractic\Data\Types\Set

Get the tags associated with this event

NOTE: This returns a Set

Returns

\Phabstractic\Event\Resource\Phabstractic\Data\Types\Set

addTag()

addTag(string  $tag) 

Associate a tag with this event

Parameters

string $tag

addTags()

addTags(array  $tags) 

Add multiple tags to the event

Parameters

array $tags

setTags()

setTags(array  $tags) 

Set a bunch of tags to be associated with this event

Parameters

array $tags

removeTag()

removeTag(string  $tag) 

Dissasociate a particular tag from this event

Parameters

string $tag

isTag()

isTag(string  $tag) : boolean

Is a tag associated with this particular event

Parameters

string $tag

Returns

boolean

getTarget()

getTarget() : object

Returns the generator of the event

Returns

object

getTargetReference()

getTargetReference() : object

Returns the generator of the event's reference

Returns

object

setTarget()

setTarget(  $target) 

Sets the generator of the event

NOTE: Use this function out of the construction of an event with caution

Parameters

$target

setTargetReference()

setTargetReference(  $target) 

Sets the generator of the event's reference

Parameters

$target

getData()

getData() : mixed

Retrieve the data associated with the event

Returns

mixed

getDataReference()

getDataReference() : mixed

Retrieve the data associated with the event as a reference

Returns

mixed

setData()

setData(mixed  $data) 

Set the data associated with this event

This is implementation specific

Parameters

mixed $data

setDataReference()

setDataReference(mixed  $data) 

Set the data associated with this event as a reference

This is implementation specific

Parameters

mixed $data

getFunction()

getFunction() : string

Retrieve the event originating function

Returns

string

getClass()

getClass() : string

Retrieve the event originating class

Returns

string

getNamespace()

getNamespace() : string

Retrieve the event originating namespace

Returns

string

stop()

stop() 

Stop propagation of the event

This member is checked by the filters

proceed()

proceed() 

Allow the event to continue propogating

isStopped()

isStopped() : boolean

Has the propogation of this event stopped?

Returns

boolean

force()

force() 

Make this event unstoppable

subdue()

subdue() 

Make this event stoppable

isUnstoppable()

isUnstoppable() : boolean

Is this event unstoppable?

Checked by filters

Returns

boolean

__debugInfo()

__debugInfo() 

Debug Info (var_dump)

Display debug info

Requires PHP 5.6+

getNewIdentity()

getNewIdentity() : mixed

Poll for New Identity

Overridable in a using class so that anything could be used as an identity, but by default it's an integer attached to a prefix. As new identities are polled, the integer increases.

Returns

mixed —

The new identity

setIdentifier()

setIdentifier(  $identifier = '') 

Set an Identifier

For the generic class we just generate a unique id

Parameters

$identifier

The identifier to set