Streams_Message Class
Class representing 'Message' rows in the 'Streams' database You can create an object of this class either to access its non-static methods, or to actually represent a message row in the Streams database.
Item Index
Methods
Methods
__set_state
-
$array
Implements the __set_state method, so it can work with with var_export and be re-imported successfully.
Parameters:
-
$array
Array
Returns:
Class instance
clearInstruction
-
$instructionName
Parameters:
-
$instructionName
StringThe name of the instruction to remove
exportArray
-
$options=null
Convert message object to array safe to show to a user
Parameters:
-
$options=null
Array
Returns:
getAllinstructions
()
Array
Returns:
The array of all instructions set in the message
getInstruction
-
$instructionName
-
$default
Parameters:
-
$instructionName
StringThe name of the instruction to get
-
$default
MixedThe value to return if the instruction is missing
Returns:
The value of the instruction, or the default value, or null
post
-
$asUserId
-
$publisherId
-
$streamName
-
$message
-
$skipAccess=false
Post a message to stream
Parameters:
-
$asUserId
StringThe user to post the message as
-
$publisherId
StringThe publisher of the stream
-
$streamName
String | ArrayThe name of the stream. You can also pass an array of stream names here.
-
$message
ArrayThe fields of the message that you want posted.
-
$skipAccess=false
BooleamIf true, skips the access checks and just posts the message.
Returns:
If $streamName was a string, returns the Streams_Message that was posted. If $streamName was an array, returns an array of ($streamName => $message) pairs
postMessages
-
$asUserId
-
$messages
-
$skipAccess=false
Post (potentially) multiple messages to multiple streams.
Parameters:
-
$asUserId
StringThe user to post the message as
-
$messages
StringArray indexed as follows: array($publisherId => array($streamName => $message)) where $message are either Streams_Message objects, or arrays containing all the fields of messages that will need to be posted.
-
$skipAccess=false
BooleamIf true, skips the access checks and just posts the message.
Returns:
Returns an array(array(Streams_Message), array(Streams_Stream))
setInstruction
-
$instructionName
-
$value
Parameters:
-
$instructionName
String | ArrayThe name of the instruction to set, or an array of $instructionName => $value pairs
-
$value
MixedThe value to set the instruction to
Returns:
Streams_Message
setUp
()
The setUp() method is called the first time an object of this class is constructed.
Events
Streams/message/$messageType
Before
Event Payload:
-
publisherId
String -
stream
Streams_Stream -
message
String
Streams/message/$messageType
After
Event Payload:
-
publisherId
String -
stream
Streams_Stream -
message
String
Streams/post/$streamType
Before
Event Payload:
-
publisherId
String -
stream
Streams_Stream -
message
String
Streams/post/$streamType
After
Event Payload:
-
publisherId
String -
stream
Streams_Stream -
message
String