PHP 클래스 Pheasant\DomainObject

상속: implements ArrayAccess
파일 보기 프로젝트 열기: lox/pheasant 1 사용 예제들

공개 메소드들

메소드 설명
__callStatic ( $method, $params ) Delegates find calls through to the finder
__construct ( ) The final constructer which initializes the object. Subclasses can implement {@link construct()} instead
__get ( $key ) Magic method, delegates to the schema for getters
__isset ( $key ) Magic method, delegates to the schema
__set ( $key, $value ) Magic method, delegates to the schema for setters
__toString ( ) String coercion. Returns a value like "ClassName[pkcol1=foo,pkcol2=bar]"
changes ( ) : array Returns a key=>val array of properties that have changed since the last save
className ( ) Return the class name of the domain object
clearChanges ( ) Clears the changes array
connection ( ) : Connection Returns the connection object for the domain object.
create ( ) : DomainObject Creates and saves a domain object, var args are passed to the constructor
delete ( ) Deletes the domain object via the associated mapper
diff ( $object ) Returns keys that differ between the two objects
equals ( $object ) Compares the properties of one domain object to that of another
eventHandler ( $e, $obj ) : void Handles events for the domain object, looks for local methods named after the event, e.g beforeSave. The event is passed as a parameter
events ( $events = [] ) : Events Returns the domain objects event collection, optionally registering any passed events
fromArray ( $array = [] ) Creates an instance from an array, bypassing the constructor and setters
get ( $prop ) : mixed Gets a property
has ( $prop ) Whether the object has a property, even if it's null
identity ( ) : Identity Returns an Identity object for the domain object
import ( $records ) : array Creates and saves a array or arrays as domain objects
initialize ( $builder, $pheasant ) Template function for configuring a domain object. Looks for either a tableName() method or a mapper() method, a properties() method and a relationships() method.
isSaved ( ) : boolean Returns whether the object has been saved
load ( $array, $filter = false ) Loads an array of values into the object
lock ( $onChanged = null ) Creates a concurrency lock on the domain object, with an optional closure to execute if the object has changed in the db when the lock finally provided. Closure gets the original and the new object
markSaved ( $value = true ) Change the objects saved state
offsetExists ( $offset ) array object
offsetGet ( $offset )
offsetSet ( $offset, $value )
offsetUnset ( $offset )
override ( $property, $closure ) Defines a closure that is called when the property is accessed.
reload ( ) Reloads the contents of the object
save ( ) Saves the domain object via the associated mapper
saveAfter ( $object ) Register a domain object to be saved after the current domain object is saved
schema ( ) : Schema Returns the Schema registered for this class.
scopes ( ) Returns an array of scope functions
set ( $prop, $value ) Sets a property
toArray ( ) : array Returns the object as an array
transaction ( $closure, $execute = true ) : Transaction Creates a transaction, passes the instance

보호된 메소드들

메소드 설명
_defaultConstruct ( ) Default method called without a constructor
_registerDefaultEventHandlers ( ) Sets up the default internal event handlers
mapper ( ) : Mapper Returns the mapper for the object
properties ( ) Returns an array of Property objects
relationships ( ) Returns an array of Relationship objects
tableName ( ) : string Used by the default initialize() method, returns the table name to use

메소드 상세

__callStatic() 공개 정적인 메소드

Delegates find calls through to the finder
public static __callStatic ( $method, $params )

__construct() 최종 공개 메소드

The final constructer which initializes the object. Subclasses can implement {@link construct()} instead
final public __construct ( )

__get() 공개 메소드

Magic method, delegates to the schema for getters
public __get ( $key )

__isset() 공개 메소드

Magic method, delegates to the schema
public __isset ( $key )

__set() 공개 메소드

Magic method, delegates to the schema for setters
public __set ( $key, $value )

__toString() 공개 메소드

String coercion. Returns a value like "ClassName[pkcol1=foo,pkcol2=bar]"
public __toString ( )

_defaultConstruct() 보호된 메소드

Default method called without a constructor
protected _defaultConstruct ( )

_registerDefaultEventHandlers() 보호된 메소드

Sets up the default internal event handlers

changes() 공개 메소드

Returns a key=>val array of properties that have changed since the last save
public changes ( ) : array
리턴 array

className() 공개 정적인 메소드

Return the class name of the domain object
public static className ( )

clearChanges() 공개 메소드

Clears the changes array
public clearChanges ( )

connection() 공개 정적인 메소드

This can be overridden on a per-class basis.
public static connection ( ) : Connection
리턴 Connection

create() 공개 정적인 메소드

Creates and saves a domain object, var args are passed to the constructor
public static create ( ) : DomainObject
리턴 DomainObject

delete() 공개 메소드

Deletes the domain object via the associated mapper
public delete ( )

diff() 공개 메소드

Returns keys that differ between the two objects
public diff ( $object )

equals() 공개 메소드

Compares the properties of one domain object to that of another
public equals ( $object )

eventHandler() 공개 메소드

Handles events for the domain object, looks for local methods named after the event, e.g beforeSave. The event is passed as a parameter
public eventHandler ( $e, $obj ) : void
리턴 void

events() 공개 메소드

Returns the domain objects event collection, optionally registering any passed events
public events ( $events = [] ) : Events
리턴 Events

fromArray() 공개 정적인 메소드

Creates an instance from an array, bypassing the constructor and setters
public static fromArray ( $array = [] )

get() 공개 메소드

Gets a property
public get ( $prop ) : mixed
리턴 mixed

has() 공개 메소드

Whether the object has a property, even if it's null
public has ( $prop )

identity() 공개 메소드

Returns an Identity object for the domain object
public identity ( ) : Identity
리턴 Identity

import() 공개 정적인 메소드

Creates and saves a array or arrays as domain objects
public static import ( $records ) : array
리턴 array of saved domain objects

initialize() 공개 정적인 메소드

Template function for configuring a domain object. Looks for either a tableName() method or a mapper() method, a properties() method and a relationships() method.
public static initialize ( $builder, $pheasant )

isSaved() 공개 메소드

Returns whether the object has been saved
public isSaved ( ) : boolean
리턴 boolean

load() 공개 메소드

Loads an array of values into the object
public load ( $array, $filter = false )
$filter only processes the keys listed, or false for all

lock() 공개 메소드

Creates a concurrency lock on the domain object, with an optional closure to execute if the object has changed in the db when the lock finally provided. Closure gets the original and the new object
public lock ( $onChanged = null )

mapper() 보호된 메소드

Returns the mapper for the object
protected mapper ( ) : Mapper
리턴 Mapper

markSaved() 공개 메소드

Change the objects saved state
public markSaved ( $value = true )

offsetExists() 공개 메소드

array object
public offsetExists ( $offset )

offsetGet() 공개 메소드

public offsetGet ( $offset )

offsetSet() 공개 메소드

public offsetSet ( $offset, $value )

offsetUnset() 공개 메소드

public offsetUnset ( $offset )

override() 공개 메소드

The closure is passed the property and the domain object.
public override ( $property, $closure )

properties() 보호된 메소드

Returns an array of Property objects
protected properties ( )

relationships() 보호된 메소드

Returns an array of Relationship objects
protected relationships ( )

reload() 공개 메소드

Reloads the contents of the object
public reload ( )

save() 공개 메소드

Saves the domain object via the associated mapper
public save ( )

saveAfter() 공개 메소드

Register a domain object to be saved after the current domain object is saved
public saveAfter ( $object )

schema() 공개 정적인 메소드

Returns the Schema registered for this class.
public static schema ( ) : Schema
리턴 Schema

scopes() 공개 정적인 메소드

Returns an array of scope functions
public static scopes ( )

set() 공개 메소드

Sets a property
public set ( $prop, $value )

tableName() 보호된 메소드

Used by the default initialize() method, returns the table name to use
protected tableName ( ) : string
리턴 string

toArray() 공개 메소드

Returns the object as an array
public toArray ( ) : array
리턴 array

transaction() 공개 메소드

Creates a transaction, passes the instance
public transaction ( $closure, $execute = true ) : Transaction
리턴 Transaction