Class Phalcon\Mvc\Model\Message

implements Phalcon\Mvc\Model\MessageInterface

Encapsulates validation info generated before save/delete records fails

  1. <?php
  2. use Phalcon\Mvc\Model\Message as Message;
  3. class Robots extends \Phalcon\Mvc\Model
  4. {
  5. public function beforeSave()
  6. {
  7. if (this->name == 'Peter') {
  8. text = "A robot cannot be named Peter";
  9. field = "name";
  10. type = "InvalidValue";
  11. message = new Message(text, field, type);
  12. this->appendMessage(message);
  13. }
  14. }
  15. }

Methods

public __construct (unknown $message, [unknown $field], [unknown $type], [unknown $model])

Phalcon\Mvc\Model\Message constructor

public Phalcon\Mvc\Model\MessageInterface setType (unknown $type)

Sets message type

public string getType ()

Returns message type

public Phalcon\Mvc\Model\MessageInterface setMessage (unknown $message)

Sets verbose message

public string getMessage ()

Returns verbose message

public Phalcon\Mvc\Model\MessageInterface setField (unknown $field)

Sets field name related to message

public string getField ()

Returns field name related to message

public Phalcon\Mvc\Model\Message setModel (unknown $model)

Set the model who generates the message

public Phalcon\Mvc\ModelInterface getModel ()

Returns the model that produced the message

public string __toString ()

Magic __toString method returns verbose message

public static Phalcon\Mvc\Model\MessageInterface __set_state (unknown $message)

Magic __set_state helps to re-build messages variable exporting