core/model/modx/registry/moddbregister.class.php
This file contains a simple database implementation of modRegister.
- Package
- modx
- Subpackage
- registry
\modDbRegister
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.
- Parent(s)
- \modRegister
Properties

boolean
$__kill= 'false'
A polling flag that will terminate additional polling when true.
Inherited from: \modRegister::$$__killfalseDetails- Type
- boolean
- Inherited_from
- \modRegister::$$__kill

string
$_currentTopic= ''/''
An optional current topic to allow writes to relative paths.
Inherited from: \modRegister::$$_currentTopic'/'Details- Type
- string
- Access
- protected
- Inherited_from
- \modRegister::$$_currentTopic

string
$_key= 'null'
nullDetails- Type
- string
- Access
- protected
- Inherited_from
- \modRegister::$$_key

\modDbRegisterQueue
$_queue= 'null'
The queue object representing this modRegister instance.
nullDetails- Type
- \modDbRegisterQueue
- Access
- protected

\modX
$modx= 'null'
A reference to the modX instance the register is loaded by.
Inherited from: \modRegister::$$modxnullDetails- Type
- \modX
- Access
- public
- Inherited_from
- \modRegister::$$modx

array
$options= 'null'
nullDetails- Type
- array
- Access
- public
- Inherited_from
- \modRegister::$$options

array
$subscriptions= 'array()'
An array of topics and/or messages the register is subscribed to.
Inherited from: \modRegister::$$subscriptionsarray()Details- Type
- array
- Access
- public
- Inherited_from
- \modRegister::$$subscriptions
Methods

__construct(
\modX $modx, string $key, array $options
=
array()
)
:
voidConstruct a new modDbRegister instance.
| Name | Type | Description |
|---|---|---|
| $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 |

_initQueue(
string $key, array $options
)
:
\modDbRegisterQueueInitialize a new queue
| Name | Type | Description |
|---|---|---|
| $key | string | The new name of the queue |
| $options | array | An array of options |
| Type | Description |
|---|---|
| \modDbRegisterQueue | A reference to the new Queue object |

_readMessage(
object $obj, boolean $remove
=
true
)
:
mixedRead a message record from the queue topic.
| Name | Type | Description |
|---|---|---|
| $obj | object | The message data to read. |
| $remove | boolean | Indicates if the message should be deleted once it is read. |
| Type | Description |
|---|---|
| mixed | The message returned |
- Todo
- Implement support for reading various message types, other than executable PHP format.

abort(
$transactionKey
)
:
void| Name | Type | Description |
|---|---|---|
| $transactionKey |

acknowledge(
string $messageKey, string $transactionKey
)
:
void
| Name | Type | Description |
|---|---|---|
| $messageKey | string | The key of the message being read |
| $transactionKey | string | The secure key of the transaction that is reading |

begin(
\$transactionKey $transactionKey
)
:
void
| Name | Type | Description |
|---|---|---|
| $transactionKey | \$transactionKey | The key of the message |

close(
)
:
booleanClose the connection to the register service implementation.
| Type | Description |
|---|---|
| boolean | Indicates if the connection was closed successfully. |

commit(
string $transactionKey
)
:
void
| Name | Type | Description |
|---|---|---|
| $transactionKey | string | The key of the transaction |

connect(
array $attributes
=
array()
)
:
booleanConnect to the register service implementation. If we made it here, we connected fine.
| Name | Type | Description |
|---|---|---|
| $attributes | array | A collection of attributes required for connection to the register. |
| Type | Description |
|---|---|
| boolean | Indicates if the connection was successful. |

read(
array $options
=
array()
)
:
mixedThis 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.
| Name | Type | Description |
|---|---|---|
| $options | array | An array of general or protocol specific options. |
| Type | Description |
|---|---|
| mixed | The resulting message from the register. |

send(
string $topic, mixed $message, array $options
=
array()
)
:
booleanThis 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.
| Name | Type | Description |
|---|---|---|
| $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. |
| Type | Description |
|---|---|
| boolean | Indicates if the message was recorded. |
- Todo
- Implement support for sending various message types, other than executable PHP format.

setCurrentTopic(
string $topic
)
:
void
| Name | Type | Description |
|---|---|---|
| $topic | string | The key of the topic |

subscribe(
string $topic
)
:
booleanSubscribe to a topic (or specific message) in the register.
Inherited from: \modRegister::subscribe()| Name | Type | Description |
|---|---|---|
| $topic | string | The path representing the topic or message. |
| Type | Description |
|---|---|
| boolean | Indicates if the subscription was successful. |

unsubscribe(
string $topic
)
:
booleanUnsubscribe from a topic (or specific message) in the register.
Inherited from: \modRegister::unsubscribe()| Name | Type | Description |
|---|---|---|
| $topic | string | The path representing the topic or message. |
| Type | Description |
|---|---|
| boolean | Indicates if the subscription was removed successfully. |