CALLBACK_POSITION_PREPEND
CALLBACK_POSITION_PREPEND
Class MessageLocator
addMissingMessageHandler(callable $locator, integer $position = self::CALLBACK_POSITION_APPEND) : $this
Append a function to handle missing messages.
The callbacks given to this method is executed when the corresponding MessageLocator
could not find a valid message for a given id.
The callback should return a string.
The callback may also prevent return false to allow subsequent callbacks to execute.
$locator->addMissingMessageHandler(function($msgId, MessageLocator $locator) {
if(MyOwnLocator::canLocate($msgId)) {
return $msg;
}
$locator->terminateCallbackChain();
});
callable | $locator | |
integer | $position |
fromPhpFile( $string) : \Pvra\Result\MessageLocator
$string |
offsetSet(null $offset, callable $value)
Appends a new message searcher Only the following syntax is valid: `$locator[] = function($id, $locator) {};
null | $offset | |
callable | $value |
Exception is thrown if an offset is specified or the value is not callable