model/modx/registry/modfileregister.class.php

Includes Classes 
package
modx
subpackage
registry
Classes
modFileRegister

Description

This file contains a simple file-based implementation of modRegister.

\modFileRegister

Extends from
\modRegister
package
modx
Properties
$directory
Methods
__construct
_readMessage
close
connect
getSortedDirectoryListing
read
send

Description

A simple, file-based implementation of modRegister.

This implementation does not address transactional conflicts and should be used in non-critical processes that are easily recoverable.

Properties

$directory

string $directory = 'null'

A physical directory where the register stores topics and messages.

Details

string
visibility
protected
default
null
final
false
static
false

Methods

__construct

__construct( \modX $modx, string $key, array $options = array ) :

Construct a new modFileRegister instance.

{@inheritdoc}

Arguments
$modx
\modX
&$modx A reference to the modX instance
$key
string
The key of the registry to load
$options
array
An array of options to set
Details
visibility
public
final
false
static
false

_readMessage

_readMessage( string $filename, boolean $remove = true ) : mixed

Read a message file from the queue.

Arguments
$filename
string
An absolute path to a message file to read.
$remove
boolean
Indicates if the message file should be deleted once the message is read from it.
Output
mixed
The message returned
Details
visibility
private
final
false
static
false
access
private
todo
Implement support for reading various message types, other than executable PHP format.

close

close( ) : boolean

Close the connection to the register service implementation.

Output
boolean
Indicates if the connection was closed successfully.
Details
visibility
public
final
false
static
false

connect

connect( array $attributes = array ) : boolean

Make sure the register can write to the specified $directory.

{@inheritdoc}

Arguments
$attributes
array
A collection of attributes required for connection to the register.
Output
boolean
Indicates if the connection was successful.
Details
visibility
public
final
false
static
false

getSortedDirectoryListing

getSortedDirectoryListing( string $dir ) : array

Get list of topic messages from a directory sorted by modified date.

Arguments
$dir
string
A valid directory path.
Output
array
An array of topic messages sorted by modified date.
Details
visibility
private
final
false
static
false

read

read( array $options = array ) : mixed

{@inheritdoc}

This implementation supports the following options and default behavior:

  • msg_limit: Only poll until the specified limit of messages has been digested. Default is 5 messages.
  • time_limit: Poll for new messages for a specified number of seconds. Default is the result of the php time_limit system variable.
  • poll_limit: Only poll for new subscriptions a specified number of times. Default is unlimited.
  • poll_interval: Wait a specified number of seconds between each additional polling iteration, after the initial one. Default is no interval.
  • remove_read: Remove the message immediately upon digesting it. Default is true.
Arguments
$options
array
An array of general or protocol specific options.
Output
mixed
The resulting message from the register.
Details
visibility
public
final
false
static
false

send

send( string $topic, mixed $message, array $options = array ) : boolean

{@inheritdoc}

This implementation provides support for sending messages using either time-based indexes so they are consumed in the order they are produced, or named indexes typically used when consumers want to subscribe to a specific, unique message. Individual messages or message collections passed in numerically indexed arrays are treated as time-based messages and message collections passed in associative arrays are treated as named messages. e.g., to send a single message as named, wrap it in an array with the intended message name as the key.

This implementation also supports a message_type option to indicate the format of the message being sent to the register. Currently only supports executable PHP format.

Other implementation specific options include:

  • delay: Number of seconds to delay the message. This option is only supported for time-based messages.
  • ttl: Number of seconds the message is valid in the queue. Default is forever or 0.
  • kill: Tells a message consumer to stop consuming any more messages after reading any message sent with this option.
Arguments
$topic
string
A topic container in which to broadcast the message.
$message
mixed
A message, or collection of messages to be sent to the register.
$options
array
An optional array of general or protocol specific message properties.
Output
boolean
Indicates if the message was recorded.
Details
visibility
public
final
false
static
false
todo
Implement support for sending various message types, other than executable PHP format.
Documentation was generated by DocBlox 0.11.2.