Messenger

Contracts

MessengerRepositoryContract

The MessengerRepositoryContract is the interface for the messenger repository. This interface defines methods to add and show/list messages.

Namespace

Plenty\Modules\Messenger\Contracts

Methods

public add(array $data):Message

Creates a new message.

Parameters
array $data The message data to be loaded
public show(string $uuid):void

Gets a message with all its successors.

Parameters
string $uuid The UUID5 of the message
public list(string $uuid = null, bool $successors = true, int $amount = self::DEFAULT_MESSAGES_AMOUNT):array

Lists messages. If no reference UUID5 is given, the method returns the $amount first messages. If $successor is set to FALSE, the messages older than the referenced message will be returned.

Parameters
string $uuid The reference UUID5 of the message to start from (excluding). If not set, the uuid of the newest message will be used.
bool $successors If set to FALSE, the messages older than the referenced message will be returned.
int $amount The amount of messages to list (defaults to 50)
public getMessages(int $page = self::DEFAULT_PAGE_OF_MESSAGES, int $itemsPerPage = self::DEFAULT_ITEMS_PER_PAGE_OF_MESSAGES):array

Lists messages.

Parameters
int $page The number of the returned page of messages, default is 1 (the first)
int $itemsPerPage The amount of messages to list (defaults to 50)
public updateReadBy(int $readBy, string $uuid):void

Updates the readBy array of the message.

Parameters
int $readBy The ID of the user who read the message
string $uuid The UUID of the message
public updateVisibility(array $data, string $uuid):void

Updates the visibility of the message. Attributes that are updated are Message.visibility, Message.linkedTo and Message.accessFor.

Parameters
array $data The message with the data to be updated
string $uuid The UUID of the messages
public updateControls(array $data, string $uuid):Message

Updates the message ui control options in the message meta data and returns the message.

Parameters
array $data The controls data to be updated.
string $uuid The uuid of the message.
public setDone(string $doneAt = null, string $uuid):void

Sets the doneAt date in the message. If $doneAt is NULL, the doneAt date will be reset.

Parameters
string $doneAt The doneAt date as ISO date string
string $uuid The UUID of the message
public delete(string $uuid):int

Deletes a message stream by the UUID. Returns the count of messages deleted.

Parameters
string $uuid The UUID of the message
public getAttachment(string $uuid, string $filename):Attachment

Gets a message attachment.

Parameters
string $uuid The UUID of the message
string $filename The file name of the attachment
public updateMetaData(string $uuid, array $metaData):Message

Updates the meta data of the message.

Parameters
string $uuid The UUID of the message
array $metaData The meta data of the message
public getTotalEntries():int

Returns total message entries

public setFilters(array $filters = []):void

Sets the filter array.

Parameters
array $filters
public getFilters():void

Returns the filter array.

public getConditions():void

Returns a collection of parsed filters as Condition object

public clearFilters():void

Clears the filter array.

Models

MessageMetaData

The MessageMetaData model of the messenger.

Namespace

Plenty\Modules\Messenger\Models

Properties

Type Name Description
array readBy The array of users
array links Array with links
MessageMetaDataNotDone notDoneByBackend deactivates the toggle button in the messenger ui (backend) also has optional tooltips (reason for the deactivated toggle)
MessageMetaDataControls controls An object with control options for the ui.

Methods

public toArray()

Returns this model as an array.

MessageMetaDataControls

The message controls model. Currently supported controls:

  • <ul>
  • <li><tt>bool replyable</tt>
  •  Indicates whether or not is allowed to reply to this message stream (default true).
    
  •  It is a global control and effects only in the parent message of a stream.&lt;/li&gt;
    
  • <li><tt>bool attachable</tt>
  •  Indicates whether or not is allowed to attach files in a message (default true).
    
  •  It is a global control and effects only in the parent message of a stream.&lt;/li&gt;
    
  • <li><tt>bool linksDisabled</tt>
  •  Indicates whether or not the message links should be disabled (default false).
    
  •  It is a loacal control and effects every message.&lt;/li&gt;
    
  • </ul>

Namespace

Plenty\Modules\Messenger\Models

Properties

Type Name Description
bool replyable Indicates whether or not is allowed to reply to this message stream (default true).
bool attachable Indicates whether or not is allowed to attach files in a message (default true).
bool linksDisabled Indicates whether or not the message links should be disabled (default false).

Methods

public toArray()

Returns this model as an array.

MessageMetaDataNotDone

The MessageMetaDataNotDone model of the messenger.

Namespace

Plenty\Modules\Messenger\Models

Properties

Type Name Description
bool deactivated Deactivates the toggle button for the UI
array tooltips Tooltips for the UI to show why the toggle is deactivated (if not set, show default values)

Methods

public toArray()

Returns this model as an array.

MessageLinkedTo

The MessageLinkedTo model of the messenger.

Namespace

Plenty\Modules\Messenger\Models

Properties

Type Name Description
string type The type of the link (one of {@link MessageTypesService::LINKED_TO_TYPE_MESSAGE}, {@link MessageTypesService::LINKED_TO_TYPE_ORDER}, {@link MessageTypesService::LINKED_TO_TYPE_CONTACT} and {@link MessageTypesService::LINKED_TO_TYPE_PAYMENT})
value The value of the link. For type {@link MessageTypesService::LINKED_TO_TYPE_MESSAGE} it is a string (uuid5) and an integer otherwise.
typeId This can be the ID of a sub-type (e.g. the order subTypeId). (optional)

Methods

public toArray()

Returns this model as an array.

MessageReferrer

The MessageReferrer model of the messenger.

Namespace

Plenty\Modules\Messenger\Models

Properties

Type Name Description
string type The type of the from instance (one of {@link MessageTypesService::REFERRER_TYPE_SYSTEM}, {@link MessageTypesService::REFERRER_TYPE_BACKEND}, {@link MessageTypesService::REFERRER_TYPE_REST} and {@link MessageTypesService::REFERRER_TYPE_PLUGIN})
value The value of the instance. It is an integer (the user id) for type {@link MessageTypesService::REFERRER_TYPE_SYSTEM}, {@link MessageTypesService::REFERRER_TYPE_BACKEND} and {@link MessageTypesService::REFERRER_TYPE_REST} and a string (the plugin name) for type {@link MessageTypesService::REFERRER_TYPE_PLUGIN}.
string name An optional name for the instance. For type {@link MessageTypesService::REFERRER_TYPE_PLUGIN} it is the plugin namespace, the user name otherwise.

Methods

public toArray()

Returns this model as an array.

MessageMetaLink

The MessageMetaLink model of the messenger.

Namespace

Plenty\Modules\Messenger\Models

Properties

Type Name Description
string image An optional image URL for the link
string caption The caption to be shown for the link
string url The link URL
  • for {@link MessageMetaLink::TYPE_MAILTO} the email
  • for {@link MessageMetaLink::TYPE_URL} the complete URL with protocol
  • for {@link MessageMetaLink::TYPE_PLUGIN} the relative route to the backend
  • not needed for {@link MessageMetaLink::TYPE_REPLY}
string type One of the constants:
  • {@link MessageMetaLink::TYPE_MAILTO}
  • {@link MessageMetaLink::TYPE_URL}
  • {@link MessageMetaLink::TYPE_PLUGIN}
  • {@link MessageMetaLink::TYPE_REPLY}
string content The reply content, only needed for type {@link MessageMetaLink::TYPE_REPLY}

Methods

public toArray()

Returns this model as an array.

MessageFrom

The MessageFrom model of the messenger.

Namespace

Plenty\Modules\Messenger\Models

Properties

Type Name Description
string type The type of the from instance (one of {@link MessageTypesService::FROM_TYPE_USER}, {@link MessageTypesService::FROM_TYPE_CONTACT} and {@link MessageTypesService::FROM_TYPE_EMAIL})
value The value of the instance. For type {@link MessageTypesService::FROM_TYPE_EMAIL} it is a string (the email) and the id of the user or the contact otherwise.
string name An optional name for the instance, e.g. the real name for type {@link MessageTypesService::FROM_TYPE_EMAIL}

Methods

public toArray()

Returns this model as an array.

Attachment

The Attachment model of the messenger.

Namespace

Plenty\Modules\Messenger\Models

Properties

Type Name Description
string name The file name of the attachment
string message The UUID of the message the attachment belongs to
int size The size of the attachment in bytes
string contentType The content type fo the attachment
string content The content of the attachment
string createdAt The createdAt date of the attachment

Methods

public toArray()

Returns this model as an array.

Message

The Message model of the messenger.

Namespace

Plenty\Modules\Messenger\Models

Properties

Type Name Description
string uuid The UUID5 identifier of the message
string plentyIdHash The plenty ID hash
string parentUuid The UUID5 of the parent message
array linkedTo An array with MessageLinkedTo instances
MessageFrom from The sender of the message as MessageFrom instance.
MessageTo to The user and role IDs and emails receiving the message
bool whispered Whether the message is whispered (not visible for the contact/order linked to the message) or not
array tags An array with tag IDs assigned to the message
string title The title of the message
string preview The first two lines of the message without any markup
string message The content of the message
int attachedFilesCount The amount of attached files (readonly)
MessageReferrer referrer The message referrer
MessageMetaData metaData The meta data of the message
string doneAt The date the messages was set to done
string createdAt The creation date of the message
string updatedAt The date of the last update of the message
string deletedAt The date the message was deleted
int deletedBy The ID of the user who deleted the message
array attachments The message attachments

Methods

public toArray()

Returns this model as an array.

MessageTo

The MessageTo model of the messenger.

Namespace

Plenty\Modules\Messenger\Models

Properties

Type Name Description
array user An array with user IDs of users receiving the message
array role An array with user role IDs of user roles receiving the message
array email An array with emails receiving the message
bool allUsers Flag indicating that all system users receive the message

Methods

public toArray()

Returns this model as an array.

Events

MessageCreated

The event is triggered after a new message was created.

Namespace

Plenty\Modules\Messenger\Events

Methods

public isFirstMessage():bool

If TRUE, the message is the first one. Otherwise, it is a reply message.

public getMessage():Message

Get the message.

Services

MessagesSearchService

Search service for the messenger.

Namespace

Plenty\Modules\Messenger\Services

Methods

public find(string $uuid):Message

Gets the message with the given uuid.

Parameters
string $uuid The UUID of the message
public findOrFail(string $uuid):Message

Gets the message with the given UUID.

Parameters
string $uuid The UUID of the message
public findMany(string $uuid):array

Gets a stream of messages. The given UUID can be the UUID of the first message in the stream or one of the replied messages.

Parameters
string $uuid The UUID of the message
public navigate(int $page = 1, int $itemsPerPage = 50):array

Lists the messages for the given navigation page.

Parameters
int $page The page of results to search for
int $itemsPerPage The number of items to list per page
public getTotalEntries():int

Returns total entries

public toArray():array
public process(array $data):array
Parameters
array $data
public getFilter():array
public getPostFilter():array
public getQuery():array
public getAggregations():array
public getSuggestions():array
public getSources():void
public addDependenciesToSource($sources):void
Parameters
$sources
public getName():void
public setName($name):void
Parameters
$name
public setIsSourceDisabled(bool $isSourceDisabled):void
Parameters
bool $isSourceDisabled
public addFilter(TypeInterface
 $filter):Search
Parameters
TypeInterface $filter
public addPostFilter(TypeInterface
 $filter):Search
Parameters
TypeInterface $filter
public addQuery(TypeInterface
 $query):Search
Parameters
TypeInterface $query
public addSource(SourceInterface
 $source):Search
Parameters
SourceInterface $source
public setSorting(SortingInterface
 $sorting):Search
Parameters
SortingInterface $sorting
public addAggregation(AggregationInterface
 $aggregation):Search
Parameters
AggregationInterface $aggregation
public addSuggestion(SuggestionInterface
 $suggestion):Search
Parameters
SuggestionInterface $suggestion
public setPage(int $page, int $rowsPerPage):Search
Parameters
int $page
int $rowsPerPage
public setCollapse(CollapseInterface
 $collapse):void
Parameters
CollapseInterface $collapse
public setScoreModifier(ScoreModifierInterface
 $scoreModifier):Search
Parameters
ScoreModifierInterface $scoreModifier
public setMaxResultWindow(int $maxResults = 10000):void
Parameters
int $maxResults
public setIndex($index):void
Parameters
$index
public getFilterRaw():void
public getQueriesRaw():void
public getAggregationsRaw():array
public getSorting():void
public getScoreModifier():void

MessageTypesService

Types and type validation for several types in the messenger.

Namespace

Plenty\Modules\Messenger\Services

Methods

public static getValidLinkedToTypes():array

Gets the valid types for "linked to" references.

public static isValidLinkedTo(string $linkType, $linkValue):bool

Checks whether the given link is valid or not.

Parameters
string $linkType The link type
$linkValue The link value
public static getValidFromTypes():array

Gets the valid types for "from" references.

public static isValidFrom(string $fromType, $fromValue):bool

Checks whether the given from is valid or not.

Parameters
string $fromType The from type
$fromValue The from value
public static getValidReferrerTypes():array

Gets the valid types for "referrer" references.

public static isValidReferrer(string $referrerType, $referrerValue, string $referrerName = null):bool

Checks whether the given referrer reference is valid or not.

Parameters
string $referrerType The reference to be checked
$referrerValue The value of the reference
string $referrerName The name of the reference
public static getValidToTypes():array

Gets the valid key types for the 'to' array.

public static isValidTo(string $toKey):bool

Checks whether the given key has a valid value for to.

Parameters
string $toKey The to key