PHP 클래스 ActiveRecord\Errors

상속: implements IteratorAggregat\IteratorAggregate
파일 보기 프로젝트 열기: jpfuentes2/php-activerecord 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$DEFAULT_ERROR_MESSAGES

공개 메소드들

메소드 설명
__construct ( ActiveRecord\Model $model ) : Errors Constructs an {@link Errors} object.
__get ( string $attribute ) : array Retrieve error messages for an attribute.
__toString ( ) : string Convert all error messages to a String.
add ( string $attribute, string $msg ) Add an error message.
add_on_blank ( string $attribute, string $msg ) Adds the error message only if the attribute value was null or an empty string.
add_on_empty ( string $attribute, string $msg ) Adds an error message only if the attribute value is {@link http://www.php.net/empty empty}.
clear ( ) Clears out all error messages.
clear_model ( ) Nulls $model so we don't get pesky circular references. $model is only needed during the validation process and so can be safely cleared once that is done.
full_messages ( ) : array Returns all the error messages as an array.
getIterator ( ) : ArrayIterator Returns an iterator to the error messages.
get_raw_errors ( ) Returns the internal errors object.
is_empty ( ) : boolean Returns true if there are no error messages.
is_invalid ( string $attribute ) : boolean Returns true if the specified attribute had any error messages.
on ( string $attribute ) : string/array Returns the error message(s) for the specified attribute or null if none.
size ( ) : integer Returns the number of error messages there are.
to_array ( callable $closure = null ) : array Returns all the error messages as an array, including error key.

메소드 상세

__construct() 공개 메소드

Constructs an {@link Errors} object.
public __construct ( ActiveRecord\Model $model ) : Errors
$model ActiveRecord\Model The model the error is for
리턴 Errors

__get() 공개 메소드

Retrieve error messages for an attribute.
public __get ( string $attribute ) : array
$attribute string Name of an attribute on the model
리턴 array or null if there is no error.

__toString() 공개 메소드

This function is called implicitely if the object is casted to a string: echo $error; # "Name can't be blank\nState is the wrong length (should be 2 chars)"
public __toString ( ) : string
리턴 string

add() 공개 메소드

Add an error message.
public add ( string $attribute, string $msg )
$attribute string Name of an attribute on the model
$msg string The error message

add_on_blank() 공개 메소드

Adds the error message only if the attribute value was null or an empty string.
public add_on_blank ( string $attribute, string $msg )
$attribute string Name of an attribute on the model
$msg string The error message

add_on_empty() 공개 메소드

Adds an error message only if the attribute value is {@link http://www.php.net/empty empty}.
public add_on_empty ( string $attribute, string $msg )
$attribute string Name of an attribute on the model
$msg string The error message

clear() 공개 메소드

Clears out all error messages.
public clear ( )

clear_model() 공개 메소드

Nulls $model so we don't get pesky circular references. $model is only needed during the validation process and so can be safely cleared once that is done.
public clear_model ( )

full_messages() 공개 메소드

$model->errors->full_messages(); # array( # "Name can't be blank", # "State is the wrong length (should be 2 chars)" # )
public full_messages ( ) : array
리턴 array

getIterator() 공개 메소드

This will allow you to iterate over the {@link Errors} object using foreach. foreach ($model->errors as $msg) echo "$msg\n";

get_raw_errors() 공개 메소드

$model->errors->get_raw_errors(); # array( # "name" => array("can't be blank"), # "state" => array("is the wrong length (should be 2 chars)", # )
public get_raw_errors ( )

is_empty() 공개 메소드

Returns true if there are no error messages.
public is_empty ( ) : boolean
리턴 boolean

is_invalid() 공개 메소드

Returns true if the specified attribute had any error messages.
public is_invalid ( string $attribute ) : boolean
$attribute string Name of an attribute on the model
리턴 boolean

on() 공개 메소드

Returns the error message(s) for the specified attribute or null if none.
public on ( string $attribute ) : string/array
$attribute string Name of an attribute on the model
리턴 string/array

size() 공개 메소드

Returns the number of error messages there are.
public size ( ) : integer
리턴 integer

to_array() 공개 메소드

$model->errors->errors(); # array( # "name" => array("Name can't be blank"), # "state" => array("State is the wrong length (should be 2 chars)") # )
public to_array ( callable $closure = null ) : array
$closure callable Closure to fetch the errors in some other format (optional) This closure has the signature function($attribute, $message) and is called for each available error message.
리턴 array

프로퍼티 상세

$DEFAULT_ERROR_MESSAGES 공개적으로 정적으로 프로퍼티

public static $DEFAULT_ERROR_MESSAGES