Messages\Exception
ClassSource on GitHubExceptions thrown in Phalcon\Messages* classes will use this class
\ExceptionPhalcon\Messages\Exception
Messages\Exceptions\MessageNotObject
ClassSource on GitHub\ExceptionPhalcon\Messages\ExceptionPhalcon\Messages\Exceptions\MessageNotObject
Uses Phalcon\Messages\Exception
Method Summary
Methods
__construct()
public function __construct();Messages\Exceptions\MessagesNotIterable
ClassSource on GitHub\ExceptionPhalcon\Messages\ExceptionPhalcon\Messages\Exceptions\MessagesNotIterable
Uses Phalcon\Messages\Exception
Method Summary
Methods
__construct()
public function __construct();Messages\Message
ClassSource on GitHubClass Message
Stores a message from various components
Phalcon\Messages\Message- implementsPhalcon\Messages\MessageInterface,\JsonSerializable
Uses JsonSerializable · Phalcon\Contracts\Messages\MessagesTypes
Method Summary
public__construct(string $message,string $field = "",string $type = "",int $code = 0,array $metaData = [])Phalcon\Messages\Message constructor
publicstring__toString()Magic __toString method returns verbose message
publicintgetCode()publicstringgetField()publicstringgetMessage()publicarraygetMetaData()publicstringgetType()publicarrayjsonSerialize()Serializes the object for json_encode
publicMessageInterfacesetCode(int $code)Sets code for the message
publicMessageInterfacesetField(string $field)Sets field name related to message
publicMessageInterfacesetMessage(string $message)Sets verbose message
publicMessageInterfacesetMetaData(array $metaData)Sets message metadata
publicMessageInterfacesetType(string $type)Sets message type
Properties
protectedint$code = 0protectedstring$field = ""protectedstring$messageprotectedarray$metaData = []protectedstring$type = ""Methods
__construct()
public function __construct(
string $message,
string $field = "",
string $type = "",
int $code = 0,
array $metaData = []
);Phalcon\Messages\Message constructor
__toString()
public function __toString(): string;Magic __toString method returns verbose message
getCode()
public function getCode(): int;getField()
public function getField(): string;getMessage()
public function getMessage(): string;getMetaData()
public function getMetaData(): array;getType()
public function getType(): string;jsonSerialize()
public function jsonSerialize(): array;Serializes the object for json_encode
setCode()
public function setCode( int $code ): MessageInterface;Sets code for the message
setField()
public function setField( string $field ): MessageInterface;Sets field name related to message
setMessage()
public function setMessage( string $message ): MessageInterface;Sets verbose message
setMetaData()
public function setMetaData( array $metaData ): MessageInterface;Sets message metadata
setType()
public function setType( string $type ): MessageInterface;Sets message type
Messages\MessageInterface
InterfaceSource on GitHubInterface for Phalcon\Messages\Message
Phalcon\Messages\MessageInterface
Uses Phalcon\Contracts\Messages\MessagesTypes
Method Summary
publicstring__toString()Magic __toString method returns verbose message
publicintgetCode()Returns the message code related to this message
publicstringgetField()Returns field name related to message
publicstringgetMessage()Returns verbose message
publicarraygetMetaData()Returns message metadata
publicstringgetType()Returns message type
publicMessageInterfacesetCode(int $code)Sets code for the message
publicMessageInterfacesetField(string $field)Sets field name related to message
publicMessageInterfacesetMessage(string $message)Sets verbose message
publicMessageInterfacesetMetaData(array $metaData)Sets message metadata
publicMessageInterfacesetType(string $type)Sets message type
Methods
__toString()
public function __toString(): string;Magic __toString method returns verbose message
getCode()
public function getCode(): int;Returns the message code related to this message
getField()
public function getField(): string;Returns field name related to message
getMessage()
public function getMessage(): string;Returns verbose message
getMetaData()
public function getMetaData(): array;Returns message metadata
getType()
public function getType(): string;Returns message type
setCode()
public function setCode( int $code ): MessageInterface;Sets code for the message
setField()
public function setField( string $field ): MessageInterface;Sets field name related to message
setMessage()
public function setMessage( string $message ): MessageInterface;Sets verbose message
setMetaData()
public function setMetaData( array $metaData ): MessageInterface;Sets message metadata
setType()
public function setType( string $type ): MessageInterface;Sets message type
Messages\Messages
ClassSource on GitHubRepresents a collection of messages
Messages are stored and iterated by integer position. An entry added under a
string key through the ArrayAccess interface (for example
$messages["database"] = $message) stays reachable by that offset but is not
visited during iteration (foreach), which walks the integer sequence only.
Use the append methods (appendMessage() / appendMessages()) when entries
must take part in iteration.
Phalcon\Messages\Messages- implementsPhalcon\Contracts\Messages\Messages,\JsonSerializable
Uses Iterator · JsonSerializable · Phalcon\Contracts\Messages\Messages · Phalcon\Contracts\Messages\MessagesTypes · Phalcon\Messages\Exceptions\MessageNotObject · Phalcon\Messages\Exceptions\MessagesNotIterable · Phalcon\Messages\Traits\MessagesHelperTrait · Traversable
Method Summary
public__construct(array $messages = [])Phalcon\Messages\Messages constructor
publicvoidappendMessage(MessageInterface $message)Appends a message to the collection
publicappendMessages(mixed $messages)Appends an array of messages to the collection
publicarrayfilter(string $fieldName)Filters the message collection by field name
publicarrayjsonSerialize()Returns serialised message objects as array for json_encode. Calls
Methods
__construct()
public function __construct( array $messages = [] );Phalcon\Messages\Messages constructor
appendMessage()
public function appendMessage( MessageInterface $message ): void;Appends a message to the collection
$messages->appendMessage(
new \Phalcon\Messages\Message("This is a message")
);appendMessages()
public function appendMessages( mixed $messages );Appends an array of messages to the collection
$messages->appendMessages($messagesArray);Accepts an array of MessageInterface objects or an Iterator yielding them. The parameter stays untyped so that a non-iterable argument reaches the guard below and raises MessagesNotIterable rather than a TypeError.
filter()
public function filter( string $fieldName ): array;Filters the message collection by field name
jsonSerialize()
public function jsonSerialize(): array;Returns serialised message objects as array for json_encode. Calls jsonSerialize on each object if present
$data = $messages->jsonSerialize();
echo json_encode($data);Messages\Traits\MessagesHelperTrait
TraitSource on GitHubTrait MessagesHelperTrait
Phalcon\Messages\Traits\MessagesHelperTrait
Uses Phalcon\Contracts\Messages\MessagesTypes · Phalcon\Messages\Exceptions\MessageNotObject · Phalcon\Messages\MessageInterface
Used by Phalcon\Messages\Messages
Method Summary
publicintcount()Returns the number of messages in the list
publicMessageInterfacecurrent()Returns the current message in the iterator
publicintkey()Returns the current position/key in the iterator
publicvoidnext()Moves the internal iteration pointer to the next position
publicbooloffsetExists(mixed $offset)Checks if an index exists
publicmixedoffsetGet(mixed $offset)Gets an attribute a message using the array syntax
publicvoidoffsetSet(mixed $offset,mixed $value)Sets an attribute using the array-syntax
publicvoidoffsetUnset(mixed $offset)Removes a message from the list
publicvoidrewind()Rewinds the internal iterator
publicboolvalid()Check if the current message in the iterator is valid
Properties
protectedmessages_list$messages = []protectedint$position = 0Methods
count()
public function count(): int;Returns the number of messages in the list
current()
public function current(): MessageInterface;Returns the current message in the iterator
key()
public function key(): int;Returns the current position/key in the iterator
next()
public function next(): void;Moves the internal iteration pointer to the next position
offsetExists()
public function offsetExists( mixed $offset ): bool;Checks if an index exists
var_dump(
isset($message["database"])
);offsetGet()
public function offsetGet( mixed $offset ): mixed;Gets an attribute a message using the array syntax
print_r(
$messages[0]
);offsetSet()
public function offsetSet(
mixed $offset,
mixed $value
): void;Sets an attribute using the array-syntax
$messages[0] = new \Phalcon\Messages\Message("This is a message");offsetUnset()
public function offsetUnset( mixed $offset ): void;Removes a message from the list
unset($message["database"]);rewind()
public function rewind(): void;Rewinds the internal iterator
valid()
public function valid(): bool;Check if the current message in the iterator is valid