Messenger

Contracts

MessengerRepositoryContract

The contract defines methods to add and show/list messages.

Namespace

Plenty\Modules\Messenger\Contracts

Methods

public add(array $data):Message

Create a new Message.

Parameters
array $data
public show(string $uuid):void

Show 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

List messages.

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

Get messages.

Parameters
int $page The number of the retured 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

Update ReadBy Array of message

Parameters
int $readBy
string $uuid
public updateVisibility(array $data, string $uuid):void

Update the visibility of the message.

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

Set the doneAt date in the message.

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 uuid.

Parameters
string $uuid
public getAttachment(string $uuid, string $filename):Attachment

Get a message attachment.

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

Update meta data from message

Parameters
string $uuid
array $metaData
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 messenger MessageMetaData model

Namespace

Plenty\Modules\Messenger\Models

Properties

Type Name Description
array readBy array of users

Methods

public toArray()

Returns this model as an array.

MessageLinkedTo

The messenger MessageLinkedTo model

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 messenger MessageReferrer model

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.

MessageFrom

The messenger MessageFrom model

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 messenger Attachment model

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

Methods

public toArray()

Returns this model as an array.

Message

The messenger Message model

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 recieving the message.
bool whispered Whether the message is wispered (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 message metadata
string doneAt The date the messages setted 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 deleted the message.
array attachments The message attachments.

Methods

public toArray()

Returns this model as an array.

MessageTo

The messenger MessageTo model

Namespace

Plenty\Modules\Messenger\Models

Properties

Type Name Description
array user An array with user ids of user recieving the message.
array role An array with user role ids of user roles recieving the message.
array email An array with emails recieving the message
bool allUsers A flag indicating that all system user recieve 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 <tt>TRUE</tt>, the message is the first one, otherwise an answer 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

Find the message with the given uuid.

Parameters
string $uuid
public findOrFail(string $uuid):Message

Find the message with the given uuid.

Parameters
string $uuid
public findMany(string $uuid):array

Find a stream of messages.

Parameters
string $uuid
public navigate(int $page = 1, int $itemsPerPage = 50):array

Get the messages for the given navigation page.

Parameters
int $page
int $itemsPerPage
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 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 messenger

Namespace

Plenty\Modules\Messenger\Services

Methods

public static getValidLinkedToTypes():array

Get 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

Get 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

Get 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
string $referrerName
public static getValidToTypes():array

Get 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