Show:

Streams_Message Class

Extends Base_Streams_Message
Module: Streams

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.

Methods

__set_state

(
  • $array
)
Streams_Message

Implements the __set_state method, so it can work with with var_export and be re-imported successfully.

Parameters:

  • $array Array

Returns:

Streams_Message:

Class instance

clearInstruction

(
  • $instructionName
)

Parameters:

  • $instructionName String

    The name of the instruction to remove

exportArray

(
  • $options=null
)
Array

Convert message object to array safe to show to a user

Parameters:

  • $options=null Array

Returns:

Array:

getAllinstructions

() Array

Returns:

Array:

The array of all instructions set in the message

getInstruction

(
  • $instructionName
  • $default
)
Mixed

Parameters:

  • $instructionName String

    The name of the instruction to get

  • $default Mixed

    The value to return if the instruction is missing

Returns:

Mixed:

The value of the instruction, or the default value, or null

post

(
  • $asUserId
  • $publisherId
  • $streamName
  • $message
  • $skipAccess=false
)
Streams_Message | Array static

Post a message to stream

Parameters:

  • $asUserId String

    The user to post the message as

  • $publisherId String

    The publisher of the stream

  • $streamName String | Array

    The name of the stream. You can also pass an array of stream names here.

  • $message Array

    The fields of the message that you want posted.

  • $skipAccess=false Booleam

    If true, skips the access checks and just posts the message.

Returns:

Streams_Message | Array:

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
)
Array static

Post (potentially) multiple messages to multiple streams.

Parameters:

  • $asUserId String

    The user to post the message as

  • $messages String

    Array 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 Booleam

    If true, skips the access checks and just posts the message.

Returns:

Array:

Returns an array(array(Streams_Message), array(Streams_Stream))

setInstruction

(
  • $instructionName
  • $value
)

Parameters:

  • $instructionName String | Array

    The name of the instruction to set, or an array of $instructionName => $value pairs

  • $value Mixed

    The 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:

Streams/message/$messageType

After

Event Payload:

Streams/notAuthorized

Before

Event Payload:

Streams/post/$streamType

Before

Event Payload:

Streams/post/$streamType

After

Event Payload:

Streams/postMessages

After

Event Payload: