\Pho\FrameworkObj

The Obj Particle

One of the three foundational nodes in the Pho Framework. Obj (short for Object) do one and only one thing, they "transmit" And that is an optional edge, most object will not have any outgoing edges.

Please note, the reason why it's called Obj internally is because starting with version 7.2, PHP no longer allows the declaration of class name "Object" as it conflicts with its inner-workings. Hence, starting with pho-framework 11.0, we will switch to Obj as an internal reference to Object particles.

Summary

Methods
Properties
Constants
registerIncomingEdges()
registerOutgoingEdges()
getRegisteredIncomingEdges()
getRegisteredOutgoingEdges()
registerHandler()
toArray()
existentials()
creator()
notifySubscribers()
exportCargo()
__construct()
context()
changeContext()
edges()
edge()
hook()
unhook()
hooks()
on()
emit()
listeners()
removeAllListeners()
No public properties found
No constants found
initializeParticle()
initializeHandler()
autoRegisterOutgoingEdges()
addEdges()
hookable()
$creator
$creator_id
$handler
$incoming_edges
$outgoing_edges
$edge_list
$context
$context_id
$hooks
$listeners
$listeners_flat
$id_generator
N/A
No private methods found
No private properties found
N/A

Properties

$creator

$creator : \Pho\Framework\Actor

Who created this node. Must point to an Actor.

Points to self by Actor particles.

Type

\Pho\Framework\Actor

$creator_id

$creator_id : string

The creator's ID

Type

string

$handler

$handler : \Pho\Framework\Handlers\Gateway

Handles catch-all method calls.

Type

\Pho\Framework\Handlers\Gateway

$incoming_edges

$incoming_edges : array

An array of incoming edge classes

Type

array

$outgoing_edges

$outgoing_edges : array

An array of outgoing edge classes

Type

array

$edge_list

$edge_list : \Pho\Lib\Graph\EdgeList

Internal variable that keeps track of edges in and out.

Type

\Pho\Lib\Graph\EdgeList

$context_id

$context_id : string

The ID of the graph context of this node

Type

string

$hooks

$hooks : 

Type

$listeners

$listeners : array

The list of listeners

Type

array

$listeners_flat

$listeners_flat : 

Type

$id_generator

$id_generator : string

ID generator is now Framework's own ID class

Type

string

Methods

registerIncomingEdges()

registerIncomingEdges(  $classes) : void

Registers the incoming edges.

The default ones for all nodes are:

  • ActorOut\Read::class
  • ActorOut\Subscribe::class
  • ObjOut\Publish::class

Parameters

$classes
Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

registerOutgoingEdges()

registerOutgoingEdges(  $classes) : void

Registers the outgoing edges.

Parameters

$classes
Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

getRegisteredIncomingEdges()

getRegisteredIncomingEdges() 

Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

getRegisteredOutgoingEdges()

getRegisteredOutgoingEdges() 

Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

registerHandler()

registerHandler(string  $key, string  $class) : void

Registers a new handler adapter.

Default handlers may be overriden.

Parameters

string $key

Adapter key; e.g. "get", "set", "form" etc.

string $class

Handler class to register. A handler class shall implement HandlerInterface

Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

toArray()

toArray() : array

Converts the object to array

Used for serialization/unserialization. Converts internal object properties into a simple format to help with reconstruction.

Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Returns

array —

The object in array format.

existentials()

existentials() 

{@inheritdoc}

Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

creator()

creator() : \Pho\Framework\Actor

Retrieves the creator of this node.

Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Returns

\Pho\Framework\Actor

notifySubscribers()

notifySubscribers(\Pho\Framework\AbstractNotification  $notification) : void

Sends notification to subscriber particles

Parameters

\Pho\Framework\AbstractNotification $notification
Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

exportCargo()

exportCargo() : array

Returns all incoming edge, outgoing edge and field keywords.

Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Returns

array —

An array of incoming edge / outgoing edge / field cargo

__construct()

__construct(\Pho\Framework\Actor  $creator, \Pho\Framework\ContextInterface  $context) 

{@inheritdoc}

Parameters

\Pho\Framework\Actor $creator
\Pho\Framework\ContextInterface $context
Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

context()

context() : \Pho\Lib\Graph\ArrayObject

Returns the context that this node is a member of.

Contexts are GraphInterface objects that contain nodes.

Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Returns

\Pho\Lib\Graph\ArrayObject —

An ArrayObject of contexts in no particular order.

changeContext()

changeContext(\Pho\Lib\Graph\GraphInterface  $context) : void

Changes the fundamental context of a node.

Rarely, a node may need its fundamental context to change after its construction. This method enables setting a new context for the node.

Parameters

\Pho\Lib\Graph\GraphInterface $context
Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

edges()

edges() : \Pho\Lib\Graph\EdgeList

Gives access to this node's EdgeList property.

EdgeList contains all the edges in and out from this node. It is also used to add new edges.

Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Returns

\Pho\Lib\Graph\EdgeList

edge()

edge(\Pho\Lib\Graph\string  $id) : \Pho\Lib\Graph\EdgeInterface

Retrieve Edge objects given its ID.

Used in serialization. This function must be implemented for a higher level package with persistence. Otherwise it has no use and no function within pho-lib-graph.

Parameters

\Pho\Lib\Graph\string $id

The Edge ID in string format

Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Returns

\Pho\Lib\Graph\EdgeInterface

hook()

hook(\Pho\Lib\Graph\string  $method, \Closure  $call) 

{@inheritDoc}

Parameters

\Pho\Lib\Graph\string $method
\Closure $call
Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

unhook()

unhook(\Pho\Lib\Graph\string  $method) 

{@inheritDoc}

Parameters

\Pho\Lib\Graph\string $method
Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

hooks()

hooks() 

Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

on()

on(\Pho\Lib\Graph\Event\string  $eventName,   $callBack, \Pho\Lib\Graph\Event\int  $priority = 100) : void

Subscribe to an event.

Parameters

\Pho\Lib\Graph\Event\string $eventName
$callBack
\Pho\Lib\Graph\Event\int $priority
Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

emit()

emit(\Pho\Lib\Graph\Event\string  $eventName, array  $arguments = array()) 

Emits an event.

This method will return true if 0 or more listeners were succesfully handled. false is returned if one of the events broke the event chain.

Pho: Please note, continueCallback does not exist with Pho

If the continueCallBack is specified, this callback will be called every time before the next event handler is called.

If the continueCallback returns false, event propagation stops. This allows you to use the eventEmitter as a means for listeners to implement functionality in your application, and break the event loop as soon as some condition is fulfilled.

Note that returning false from an event subscriber breaks propagation and returns false, but if the continue-callback stops propagation, this is still considered a 'successful' operation and returns true.

Lastly, if there are 5 event handlers for an event. The continueCallback will be called at most 4 times.

Parameters

\Pho\Lib\Graph\Event\string $eventName
array $arguments
Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

listeners()

listeners(\Pho\Lib\Graph\Event\string  $eventName, \Pho\Lib\Graph\Event\bool  $flat = false) : array<mixed,callable>

Returns the list of listeners for an event.

The list is returned as an array, and the list of events are sorted by their priority.

Parameters

\Pho\Lib\Graph\Event\string $eventName
\Pho\Lib\Graph\Event\bool $flat
Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Returns

array<mixed,callable>

removeAllListeners()

removeAllListeners(\Pho\Lib\Graph\Event\string  $eventName = null) : void

Removes all listeners.

If the eventName argument is specified, all listeners for that event are removed. If it is not specified, every listener for every event is removed.

Parameters

\Pho\Lib\Graph\Event\string $eventName
Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

initializeParticle()

initializeParticle() : void

Initializes the particle.

Its functions include:

  • adding default incoming edges.
  • discovering outgoing edges based on directory structure
  • passing the ball to Handler initializer.
Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

initializeHandler()

initializeHandler() : void

A helper method to set up edges and fields.

Its inner functions can be summarized as:

1) Uses the Loaders to

  • examine the class structures (the constants, registered edges etc) and find out incoming and outgoing edges as well as fields. 2) Load the results into Cargo objects 3) Deploy the cargo objects back into this object so that the handler can serve method calls.
Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

autoRegisterOutgoingEdges()

autoRegisterOutgoingEdges() : void

Auto-registers outgoing edge classes

Auto-registration is done by directory structure. Directories that sit in this folder, and are named after this class with "Out" suffix (such as "MyNodeOut" for a node class named "MyNode") would be candidate for auto-registration.

Please note, this does not check if it's actually an Edge class. The check is done by the OutgoingEdgeLoader class.

Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

addEdges()

addEdges(string  $direction,   $classes) : self

A helper method to register edges

Parameters

string $direction

Either incoming or outgoing

$classes
Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Returns

self

hookable()

hookable() 

Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in phar:///Users/emresokullu/Code/website/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275