1: <?php
2: /**
3: * Top level injector class for returning the default binding for an object
4: *
5: * This class returns a Horde_Injector_Binder_Implementation with the requested
6: * $interface mapped to itself. This is the default case, and for conrete
7: * classes should work all the time so long as you constructor parameters are
8: * typed.
9: *
10: * @author Bob Mckee <bmckee@bywires.com>
11: * @author James Pepin <james@jamespepin.com>
12: * @category Horde
13: * @package Injector
14: */
15: class Horde_Injector_TopLevel implements Horde_Injector_Scope
16: {
17: /**
18: * Get an Implementation Binder that maps the $interface to itself
19: *
20: * @param string $interface The interface to retrieve binding information
21: * for.
22: *
23: * @return Horde_Injector_Binder_ImplementationWithSetters
24: * A new binding object that maps the interface to itself, with
25: * setter injection.
26: */
27: public function getBinder($interface)
28: {
29: $dependencyFinder = new Horde_Injector_DependencyFinder();
30: $implementationBinder = new Horde_Injector_Binder_Implementation($interface, $dependencyFinder);
31:
32: return new Horde_Injector_Binder_AnnotatedSetters($implementationBinder, $dependencyFinder);
33: }
34:
35: /**
36: * Always return null. Object doesn't keep instance references
37: *
38: * Method is necessary because this object is the default parent Injector.
39: * The child of this injector will ask it for instances in the case where
40: * no bindings are set on the child. This should always return null.
41: *
42: * @param string $interface The interface in question
43: * @return null
44: */
45: public function getInstance($interface)
46: {
47: return null;
48: }
49:
50: }
51: