PHP Class Horde_Injector_Binder_Closure, horde

An interface may be bound to a closure. That closure must accept a Horde_Injector and return an object that satisfies the instance requirement. For example:
$injector->bindClosure('database', function($injector) { return new my_mysql(); });
Author: Bob Mckee ([email protected])
Author: James Pepin ([email protected])
Author: Chuck Hagenbuch ([email protected])
Inheritance: implements Horde_Injector_Binder
ファイルを表示 Open project: horde/horde Class Usage Examples

Public Methods

Method Description
__construct ( string $closure ) Create a new Horde_Injector_Binder_Closure instance.
create ( Horde_Injector $injector ) : Horde_Injector Create instance using a closure.
equals ( Horde_Injector_Binder $otherBinder ) : boolean
getClosure ( ) : callable Get the closure that this binder was bound to.

Method Details

__construct() public method

Create a new Horde_Injector_Binder_Closure instance.
public __construct ( string $closure )
$closure string The closure to use for creating objects.

create() public method

If the closure depends on a Horde_Injector we want to limit its scope so it cannot change anything that effects any higher-level scope. A closure should not have the responsibility of making a higher-level scope change. To enforce this we create a new child Horde_Injector. When a Horde_Injector is requested from a Horde_Injector it will return itself. This means that the closure will only ever be able to work on the child Horde_Injector we give it now.
public create ( Horde_Injector $injector ) : Horde_Injector
$injector Horde_Injector Injector object.
return Horde_Injector

equals() public method

public equals ( Horde_Injector_Binder $otherBinder ) : boolean
$otherBinder Horde_Injector_Binder
return boolean Equality.

getClosure() public method

Get the closure that this binder was bound to.
public getClosure ( ) : callable
return callable The closure this binder is bound to.