PHP Class Pheasant

Show file Open project: lox/pheasant Class Usage Examples

Public Methods

Method Description
__construct ( $dsn = null ) Constructor
connection ( $name = 'default' ) : object Returns a connection by name
connections ( ) : object Returns a the connection manager
events ( ) : Events Gets the system-wide events registry
finderFor ( $subject ) : Finder Looks up a finder for either an object or a classname
initialize ( $subject, $callback = null ) : string Initializes a domain objects schema if it has not yet been initialized
instance ( ) : Pheasant Returns the static Pheasant instance
mapperFor ( $subject ) : Mapper Looks up a mapper for either an object or a classname
register ( $class, $mapper ) Register a mapper for a class, also registers the mapper as a finder
registerFinder ( $class, $mapper ) Registers the finder for a class
registerMapper ( $class, $mapper ) Registers the mapper for a class
reset ( $instance ) Resets the default static Pheasant instance
schema ( $subject ) Gets the schema for an object, initializing it if needed.
setup ( $dsn = null ) : Pheasant Shortcut for initializing the static pheasant instance
transaction ( $closure, $execute = true ) : Transaction Creates a transaction, optionally executes

Method Details

__construct() public method

Constructor
public __construct ( $dsn = null )
$dsn string a database dsn

connection() public method

Returns a connection by name
public connection ( $name = 'default' ) : object
return object

connections() public method

Returns a the connection manager
public connections ( ) : object
return object

events() public method

Gets the system-wide events registry
public events ( ) : Events
return Events

finderFor() public method

Looks up a finder for either an object or a classname
public finderFor ( $subject ) : Finder
return Finder

initialize() public method

Initializes a domain objects schema if it has not yet been initialized
public initialize ( $subject, $callback = null ) : string
$subject either an object or classname to initialize
$callback a callback to call instead of the initialize method
return string the classname of the object

instance() public static method

Returns the static Pheasant instance
public static instance ( ) : Pheasant
return Pheasant

mapperFor() public method

Looks up a mapper for either an object or a classname
public mapperFor ( $subject ) : Mapper
return Mapper

register() public method

Register a mapper for a class, also registers the mapper as a finder
public register ( $class, $mapper )

registerFinder() public method

Registers the finder for a class
public registerFinder ( $class, $mapper )

registerMapper() public method

Registers the mapper for a class
public registerMapper ( $class, $mapper )

reset() public static method

Resets the default static Pheasant instance
public static reset ( $instance )

schema() public method

Gets the schema for an object, initializing it if needed.
public schema ( $subject )
$subject mixed either object or classname

setup() public static method

Shortcut for initializing the static pheasant instance
public static setup ( $dsn = null ) : Pheasant
return Pheasant

transaction() public static method

Creates a transaction, optionally executes
public static transaction ( $closure, $execute = true ) : Transaction
return Transaction