PHP Класс Pheasant\DomainObject

Наследование: implements ArrayAccess
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
__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