Constants

CALLBACK_POSITION_PREPEND

CALLBACK_POSITION_PREPEND

CALLBACK_POSITION_APPEND

CALLBACK_POSITION_APPEND

FORMAT_KEY_TARGET_ID

FORMAT_KEY_TARGET_ID

FORMAT_KEY_LINE

FORMAT_KEY_LINE

FORMAT_KEY_VERSION

FORMAT_KEY_VERSION

FORMAT_KEY_REASON_ID

FORMAT_KEY_REASON_ID

FORMAT_KEY_REASON_NAME

FORMAT_KEY_REASON_NAME

Properties

$terminateCallbackChain

$terminateCallbackChain : boolean

Determines if the current callback-chain should be terminated at the next iteration

Type

boolean

$inCallbackChain

$inCallbackChain : boolean

Callback execution status

Type

boolean

$throwOnMissingTemplate

$throwOnMissingTemplate : boolean

Type

boolean

$messageFormatters

$messageFormatters : array

Type

array

Methods

terminateCallbackChain()

terminateCallbackChain() 

Terminate callback chain from inside a callback

This method may be called from inside of a callback chain to break out in the next iteration *

Throws

\LogicException

Thrown if no callback chain is executing when called

__construct()

__construct(array|\Pvra\Result\MessageLocator  $locator = null, boolean  $addDefaultFormatter = true, boolean  $addDefaultExclusiveMissingMessageLocatorHandler = false, boolean  $throwOnMissingTemplate = false) 

Parameters

array|\Pvra\Result\MessageLocator $locator
boolean $addDefaultFormatter
boolean $addDefaultExclusiveMissingMessageLocatorHandler
boolean $throwOnMissingTemplate

addMessageFormatter()

addMessageFormatter(callable  $transformer, integer  $position = self::CALLBACK_POSITION_APPEND) : $this

Parameters

callable $transformer

A callback with the following signature:

function(int|string $msgId, string $template, MessageFormatter $f, array $data) : string
integer $position

Returns

$this

getFormattedMessageFromId()

getFormattedMessageFromId(  $msgId, array  $data = array()) : mixed

Parameters

$msgId
array $data

Throws

\Exception

Returns

mixed

format()

format(  $messageInfo, array  $data = array(), boolean  $runUserFormatters = true) : mixed

Parameters

$messageInfo
array $data
boolean $runUserFormatters

Returns

mixed

getMessageTemplate()

getMessageTemplate(  $msgId) : null|string

Parameters

$msgId

Throws

\Exception

Returns

null|string

messageForIdExists()

messageForIdExists(  $msgId) : boolean

Parameters

$msgId

Returns

boolean

inCallbackChain()

inCallbackChain(boolean  $areWeInCallbackChain) 

Modify the status of current callback execution

This method can be used by the callback calling code to make sure other methods react properly.

Parameters

boolean $areWeInCallbackChain

Set the status of the callback chain execution

isCallbackChainToBeTerminated()

isCallbackChainToBeTerminated() : boolean

Get the status of the callback chain termination

This method can be used to determine if the callback chain is to be terminated prematurely.

Returns

boolean

markCallbackChainTerminated()

markCallbackChainTerminated() 

Mark callback chain terminated

This method should be called after the callback chain was terminated, either by breaking out of it prematurely or after finishing all callback handlers.