[cvs] [Wiki] changed: Doc/Dev/Injector
Chuck Hagenbuch
chuck at horde.org
Fri Jan 15 16:54:49 UTC 2010
chuck Fri, 15 Jan 2010 11:54:49 -0500
Modified page: http://wiki.horde.org/Doc/Dev/Injector
New Revision: 1.4
Change log: next wiki format pass
@@ -129,9 +129,9 @@
}
}
</code>
-{warning}Factory method names can be whatever you want but they must
only require one parameter and it must be a {{Horde_Injector}}
object.{warning}
+//**Factory method names can be whatever you want but they must only
require one parameter and it must be a {{Horde_Injector}} object.**//
+++++ Implementation binders
Reflection allows us to programmatically inspect the structure of
the class that is to be instantiated. By reading the interface types
of the class constructor's parameters and then asking the injector to
create those objects as well we try to provide the requested class's
constructor with all its dependencies.
@@ -194,9 +194,9 @@
<code type="php" title="Creating an instance">
$injector->createInstance('X');
</code>
-{note}Although the return object will be new, its dependencies may
not be. The injector will search its internal instances array for an
instance matching the dependency's interface and if a match if found
it will be used. If for some reason you need to guarantee that all
dependencies are new, then you should consider using a factory
binder.{note}
+//Although the returned object will be new, its dependencies may not
be. The injector will search its internal instances array for an
instance matching the dependency's interface and if a match if found
it will be used. If for some reason you need to guarantee that all
dependencies are new, then you should consider using a factory binder.//
+++++ Getting an instance
As previously mentioned instances are pooled by the injector, so
getInstance() gives developers the opportunity to reuse objects. If an
instance exists for the requested interface it will be returned,
otherwise it will be created, added to the injectors internal
instances array, and returned.
More information about the cvs
mailing list