PHP Class Bravo3\Orm\Services\PubSubManager

Datei anzeigen Open project: bravo3/orm

Protected Properties

Property Type Description
$driver Bravo3\Orm\Drivers\PubSubDriverInterface
$event_dispatcher Symfony\Component\EventDispatcher\EventDispatcher

Public Methods

Method Description
__construct ( Bravo3\Orm\Drivers\PubSubDriverInterface $driver )
addListener ( string $channel, callable $callback, integer $priority ) : PubSubManager Add a callback to a channel which will get triggered when channel receives a message via a publisher.
eventTrigger ( array $payload ) : PubSubEvent Function triggers PubSub events based on the messages received on subscribed channels.
publish ( string $channel, string $message ) : boolean Publishes a message to the configured channel. Channel and Message length is limited based on the driver used.
removeListener ( string $channel, callable $callback ) : PubSubManager Removes the callbacks assigned to database driver PubSub mechanism.
run ( ) : void

Private Methods

Method Description
generateEventName ( $channel ) : string Returns the event name with the prefix prepended.

Method Details

__construct() public method

public __construct ( Bravo3\Orm\Drivers\PubSubDriverInterface $driver )
$driver Bravo3\Orm\Drivers\PubSubDriverInterface

addListener() public method

Add a callback to a channel which will get triggered when channel receives a message via a publisher.
public addListener ( string $channel, callable $callback, integer $priority ) : PubSubManager
$channel string
$callback callable
$priority integer Default: 0
return PubSubManager

eventTrigger() public method

Function triggers PubSub events based on the messages received on subscribed channels.
public eventTrigger ( array $payload ) : PubSubEvent
$payload array
return Bravo3\Orm\Events\PubSubEvent

publish() public method

Returns true on success of delivery of the message, or false on failure. Usually a message delivery fails if there are not subscribed clients for the channel.
public publish ( string $channel, string $message ) : boolean
$channel string
$message string
return boolean

removeListener() public method

Removes the callbacks assigned to database driver PubSub mechanism.
public removeListener ( string $channel, callable $callback ) : PubSubManager
$channel string
$callback callable
return PubSubManager

run() public method

public run ( ) : void
return void

Property Details

$driver protected_oe property

protected PubSubDriverInterface,Bravo3\Orm\Drivers $driver
return Bravo3\Orm\Drivers\PubSubDriverInterface

$event_dispatcher protected_oe property

protected EventDispatcher,Symfony\Component\EventDispatcher $event_dispatcher
return Symfony\Component\EventDispatcher\EventDispatcher