PHP Class Pheasant\DomainObject

Inheritance: implements ArrayAccess
Afficher le fichier Open project: lox/pheasant Class Usage Examples

Méthodes publiques

Méthode Description
__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

Méthodes protégées

Méthode Description
_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

Method Details

__callStatic() public static méthode

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

__construct() final public méthode

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

__get() public méthode

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

__isset() public méthode

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

__set() public méthode

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

__toString() public méthode

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

_defaultConstruct() protected méthode

Default method called without a constructor
protected _defaultConstruct ( )

_registerDefaultEventHandlers() protected méthode

Sets up the default internal event handlers

changes() public méthode

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

className() public static méthode

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

clearChanges() public méthode

Clears the changes array
public clearChanges ( )

connection() public static méthode

This can be overridden on a per-class basis.
public static connection ( ) : Connection
Résultat Connection

create() public static méthode

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

delete() public méthode

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

diff() public méthode

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

equals() public méthode

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

eventHandler() public méthode

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
Résultat void

events() public méthode

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

fromArray() public static méthode

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

get() public méthode

Gets a property
public get ( $prop ) : mixed
Résultat mixed

has() public méthode

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

identity() public méthode

Returns an Identity object for the domain object
public identity ( ) : Identity
Résultat Identity

import() public static méthode

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

initialize() public static méthode

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() public méthode

Returns whether the object has been saved
public isSaved ( ) : boolean
Résultat boolean

load() public méthode

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

lock() public méthode

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() protected méthode

Returns the mapper for the object
protected mapper ( ) : Mapper
Résultat Mapper

markSaved() public méthode

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

offsetExists() public méthode

array object
public offsetExists ( $offset )

offsetGet() public méthode

public offsetGet ( $offset )

offsetSet() public méthode

public offsetSet ( $offset, $value )

offsetUnset() public méthode

public offsetUnset ( $offset )

override() public méthode

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

properties() protected méthode

Returns an array of Property objects
protected properties ( )

relationships() protected méthode

Returns an array of Relationship objects
protected relationships ( )

reload() public méthode

Reloads the contents of the object
public reload ( )

save() public méthode

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

saveAfter() public méthode

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

schema() public static méthode

Returns the Schema registered for this class.
public static schema ( ) : Schema
Résultat Schema

scopes() public static méthode

Returns an array of scope functions
public static scopes ( )

set() public méthode

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

tableName() protected méthode

Used by the default initialize() method, returns the table name to use
protected tableName ( ) : string
Résultat string

toArray() public méthode

Returns the object as an array
public toArray ( ) : array
Résultat array

transaction() public méthode

Creates a transaction, passes the instance
public transaction ( $closure, $execute = true ) : Transaction
Résultat Transaction