Documentation

目次

前のトピックへ

< Class Phalcon\Mvc\Model\Manager

次のトピックへ

Abstract class Phalcon\Mvc\Model\MetaData >

このページ

Class Phalcon\Mvc\Model\Message

implements Phalcon\Mvc\Model\MessageInterface

Encapsulates validation info generated before save/delete records fails

<?php

use Phalcon\Mvc\Model\Message as Message;

  class Robots extends Phalcon\Mvc\Model
  {

    public function beforeSave()
    {
      if ($this->name == 'Peter') {
        $text = "A robot cannot be named Peter";
        $field = "name";
        $type = "InvalidValue";
        $message = new Message($text, $field, $type);
        $this->appendMessage($message);
     }
   }

 }

Methods

public __construct (string $message, [string $field], [string $type], [Phalcon\Mvc\ModelInterface $model])

Phalcon\Mvc\Model\Message constructor

public Phalcon\Mvc\Model\Message setType (string $type)

Sets message type

public string getType ()

Returns message type

public Phalcon\Mvc\Model\Message setMessage (string $message)

Sets verbose message

public string getMessage ()

Returns verbose message

public Phalcon\Mvc\Model\Message setField (string $field)

Sets field name related to message

public string getField ()

Returns field name related to message

public Phalcon\Mvc\Model\Message setModel (Phalcon\Mvc\ModelInterface $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\Message __set_state (array $message)

Magic __set_state helps to re-build messages variable exporting