PHP 클래스 Spot\Entity

파일 보기 프로젝트 열기: vlucas/spot2 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$_data array
$_dataModified array
$_errors array Entity error messages (may be present after save attempt)
$_inGetter array
$_inSetter array
$_isNew boolean Entity state
$_objectId string
$mapper boolean
$relationFields array Used internally so entity knows which fields are relations
$table string | null Table name
$tableOptions array Datasource options

공개 메소드들

메소드 설명
__construct ( array $data = [] ) Constructor - allows setting of object properties with array on construct
__destruct ( ) Do some cleanup of stored relations so orphaned relations are not held in memory
__get ( string $field ) : boolean | mixed | null Getter for field properties
__isset ( string $key ) : boolean Enable isset() for object properties
__set ( string $field, mixed $value ) Setter for field properties
__toString ( ) : string String representation of the class (JSON)
data ( null | array $data = null, boolean $modified = true, boolean $loadRelations = true ) Gets and sets data on the current entity
dataExcept ( array $except ) : array Return array of field data with data from the field names listed removed
dataModified ( null | string $field = null ) : array | boolean Gets data that has been modified since object construct, optionally allowing for selecting a single field
dataUnmodified ( null | string $field = null ) : array | boolean Gets data that has not been modified since object construct, optionally allowing for selecting a single field
entity ( ) Helper function so entity can be accessed via relation in a more consistent manner with 'entity()' without any errors (i.e. relation will not error if it already has a loaded entity object - it just returns $this)
error ( string $field, mixed $msg ) Add an error to error messages array
errors ( string | array $msgs = null, boolean $overwrite = true ) : array | boolean | Entity Error message getter/setter
events ( EventEmitter $eventEmitter ) Add events to this entity
fields ( ) : array Return defined fields of the entity
get ( string $field ) : boolean | mixed | null
hasErrors ( string $field = null ) : boolean Check if any errors exist
isModified ( null | string $field = null ) : boolean | null Returns true if a field has been modified.
isNew ( null $new = null ) : boolean Is entity new (unsaved)?
jsonSerialize ( ) JsonSerializable
mapper ( ) : boolean Mapper name getter
primaryKey ( ) : mixed Get the value of the primary key field defined on this entity
primaryKeyField ( ) : string Get primary key field name
relation ( string $relationName, null $relationObj = null ) : boolean | mixed Get/Set relation
relations ( spot\MapperInterface $mapper, spot\EntityInterface $entity ) : array Return defined fields of the entity
scopes ( ) Return scopes defined by this entity. Scopes are called from the Spot\Query object as a sort of in-context dynamic query method
set ( string $field, mixed $value, boolean $modified = true )
table ( string | null $tableName = null ) : string Table name getter/setter
tableOptions ( null | array $tableOpts = null ) : array Datasource options getter/setter
toArray ( ) : array Alias of self::data()

보호된 메소드들

메소드 설명
initFields ( ) Set all field values to their defaults or null

메소드 상세

__construct() 공개 메소드

Constructor - allows setting of object properties with array on construct
public __construct ( array $data = [] )
$data array

__destruct() 공개 메소드

Do some cleanup of stored relations so orphaned relations are not held in memory
public __destruct ( )

__get() 공개 메소드

Getter for field properties
public __get ( string $field ) : boolean | mixed | null
$field string
리턴 boolean | mixed | null

__isset() 공개 메소드

Enable isset() for object properties
public __isset ( string $key ) : boolean
$key string
리턴 boolean

__set() 공개 메소드

Setter for field properties
public __set ( string $field, mixed $value )
$field string
$value mixed

__toString() 공개 메소드

String representation of the class (JSON)
public __toString ( ) : string
리턴 string

data() 공개 메소드

Gets and sets data on the current entity
public data ( null | array $data = null, boolean $modified = true, boolean $loadRelations = true )
$data null | array
$modified boolean
$loadRelations boolean Determine if you want to load entity relations

dataExcept() 공개 메소드

Return array of field data with data from the field names listed removed
public dataExcept ( array $except ) : array
$except array List of field names to exclude in data list returned
리턴 array

dataModified() 공개 메소드

Gets data that has been modified since object construct, optionally allowing for selecting a single field
public dataModified ( null | string $field = null ) : array | boolean
$field null | string
리턴 array | boolean

dataUnmodified() 공개 메소드

Gets data that has not been modified since object construct, optionally allowing for selecting a single field
public dataUnmodified ( null | string $field = null ) : array | boolean
$field null | string
리턴 array | boolean

entity() 공개 메소드

Helper function so entity can be accessed via relation in a more consistent manner with 'entity()' without any errors (i.e. relation will not error if it already has a loaded entity object - it just returns $this)
public entity ( )

error() 공개 메소드

Add an error to error messages array
public error ( string $field, mixed $msg )
$field string Field name that error message relates to
$msg mixed Error message text - String or array of messages

errors() 공개 메소드

Error message getter/setter
public errors ( string | array $msgs = null, boolean $overwrite = true ) : array | boolean | Entity
$msgs string | array string|array String return errors with field key, array sets errors
$overwrite boolean
리턴 array | boolean | Entity Setter return self, getter returns array or boolean if key given and not found

events() 공개 정적인 메소드

Add events to this entity
public static events ( EventEmitter $eventEmitter )
$eventEmitter EventEmitter

fields() 공개 정적인 메소드

Return defined fields of the entity
public static fields ( ) : array
리턴 array

get() 공개 메소드

public get ( string $field ) : boolean | mixed | null
$field string
리턴 boolean | mixed | null

hasErrors() 공개 메소드

Check if any errors exist
public hasErrors ( string $field = null ) : boolean
$field string OPTIONAL field name
리턴 boolean

initFields() 보호된 메소드

Set all field values to their defaults or null
protected initFields ( )

isModified() 공개 메소드

If no field name is passed in, return whether any fields have been changed
public isModified ( null | string $field = null ) : boolean | null
$field null | string
리턴 boolean | null

isNew() 공개 메소드

Is entity new (unsaved)?
public isNew ( null $new = null ) : boolean
$new null
리턴 boolean

jsonSerialize() 공개 메소드

JsonSerializable
public jsonSerialize ( )

mapper() 공개 정적인 메소드

Mapper name getter
public static mapper ( ) : boolean
리턴 boolean

primaryKey() 공개 메소드

Get the value of the primary key field defined on this entity
public primaryKey ( ) : mixed
리턴 mixed Value of the primary key field

primaryKeyField() 공개 메소드

Get primary key field name
public primaryKeyField ( ) : string
리턴 string Primary key field name

relation() 공개 메소드

Get/Set relation
public relation ( string $relationName, null $relationObj = null ) : boolean | mixed
$relationName string
$relationObj null
리턴 boolean | mixed

relations() 공개 정적인 메소드

Return defined fields of the entity
public static relations ( spot\MapperInterface $mapper, spot\EntityInterface $entity ) : array
$mapper spot\MapperInterface
$entity spot\EntityInterface
리턴 array

scopes() 공개 정적인 메소드

Return scopes defined by this entity. Scopes are called from the Spot\Query object as a sort of in-context dynamic query method
public static scopes ( )

set() 공개 메소드

public set ( string $field, mixed $value, boolean $modified = true )
$field string
$value mixed
$modified boolean

table() 공개 정적인 메소드

Table name getter/setter
public static table ( string | null $tableName = null ) : string
$tableName string | null
리턴 string

tableOptions() 공개 정적인 메소드

Datasource options getter/setter
public static tableOptions ( null | array $tableOpts = null ) : array
$tableOpts null | array
리턴 array

toArray() 공개 메소드

Alias of self::data()
public toArray ( ) : array
리턴 array

프로퍼티 상세

$_data 보호되어 있는 프로퍼티

protected array $_data
리턴 array

$_dataModified 보호되어 있는 프로퍼티

protected array $_dataModified
리턴 array

$_errors 보호되어 있는 프로퍼티

Entity error messages (may be present after save attempt)
protected array $_errors
리턴 array

$_inGetter 보호되어 있는 프로퍼티

protected array $_inGetter
리턴 array

$_inSetter 보호되어 있는 프로퍼티

protected array $_inSetter
리턴 array

$_isNew 보호되어 있는 프로퍼티

Entity state
protected bool $_isNew
리턴 boolean

$_objectId 보호되어 있는 프로퍼티

protected string $_objectId
리턴 string

$mapper 보호되어 있는 정적으로 프로퍼티

protected static bool $mapper
리턴 boolean

$relationFields 보호되어 있는 정적으로 프로퍼티

Used internally so entity knows which fields are relations
protected static array $relationFields
리턴 array

$table 보호되어 있는 정적으로 프로퍼티

Table name
protected static string|null $table
리턴 string | null

$tableOptions 보호되어 있는 정적으로 프로퍼티

Datasource options
protected static array $tableOptions
리턴 array