This repository has been archived by the owner on Jan 8, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Zend\Di documentation initial commit
- Loading branch information
Ralph Schindler
committed
Oct 14, 2011
1 parent
e575edd
commit 59f9467
Showing
9 changed files
with
927 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
51 changes: 51 additions & 0 deletions
51
documentation/manual/en/module_specs/Zend_Di-Configuration.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- Reviewed: no --> | ||
<section | ||
xmlns="http://docbook.org/ns/docbook" version="5.0" | ||
xmlns:xlink="http://www.w3.org/1999/xlink" | ||
xml:id="zend.di.configuration"> | ||
<info><title>Zend\Di Configuration</title></info> | ||
|
||
<para> | ||
Most of the configuration for both the setup of | ||
Definitions as well as the setup of the Instance Manager | ||
can be attained by a configuration file. This file will | ||
produce an array (typically) and have a particular | ||
iterable structure. | ||
</para> | ||
|
||
<para> | ||
The top two keys are 'definition' and 'instance', each | ||
specifying values for respectively, definition setup and | ||
instance manager setup. | ||
</para> | ||
|
||
<para> | ||
The definition section expects the following information | ||
expressed as a PHP array: | ||
</para> | ||
|
||
<programlisting language="php"><![CDATA[ | ||
$config = array( | ||
'definition' => array( | ||
'compiler' => array(/* @todo compiler information */), | ||
'runtime' => array(/* @todo runtime information */), | ||
'class' => array( | ||
'instantiator' => '', // the name of the instantiator, by default this is __construct | ||
'supertypes => array(), // an array of supertypes the class implements | ||
'methods' => array( | ||
'setSomeParameter' => array( // a method name | ||
'parameterName' => array( | ||
'name', // string parameter name | ||
'type', // type or null | ||
'is-required' // bool | ||
) | ||
) | ||
) | ||
) | ||
) | ||
); | ||
]]></programlisting> | ||
|
||
</section> |
156 changes: 156 additions & 0 deletions
156
documentation/manual/en/module_specs/Zend_Di-Debugging-and-Complex-Use.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- Reviewed: no --> | ||
<section | ||
xmlns="http://docbook.org/ns/docbook" version="5.0" | ||
xmlns:xlink="http://www.w3.org/1999/xlink" | ||
xml:id="zend.di.debugging-and-complex-use-cases"> | ||
<info><title>Zend\Di Debugging & Complex Use Cases</title></info> | ||
|
||
<section xml:id="zend.di.zend.di.debugging-and-complex-use-cases.debugging"> | ||
<info><title>Debugging a DiC</title></info> | ||
|
||
<para> | ||
It is possible to dump the information contained within both the | ||
Definition and InstanceManager for a Di instance. | ||
</para> | ||
|
||
<para> | ||
The easiest way is to do the following: | ||
</para> | ||
|
||
|
||
<programlisting language="php"><![CDATA[ | ||
Zend\Di\Display\Console::export($di); | ||
]]></programlisting> | ||
|
||
<para> | ||
If you are using a RuntimeDefinition where upon you expect a | ||
particular definition to be resolve at the first-call, you can see | ||
that information to the console display to force it to read that class: | ||
</para> | ||
|
||
|
||
<programlisting language="php"><![CDATA[ | ||
Zend\Di\Display\Console::export($di, array('A\ClassIWantTo\GetTheDefinitionFor')); | ||
]]></programlisting> | ||
|
||
</section> | ||
|
||
<section xml:id="zend.di.zend.di.debugging-and-complex-use-cases.complex-use-cases"> | ||
<info><title>Complex Use Cases</title></info> | ||
|
||
<section xml:id="zend.di.zend.di.debugging-and-complex-use-cases.complex-use-cases.interface-injection"> | ||
<info><title>Interface Injection</title></info> | ||
|
||
<programlisting language="php"><![CDATA[ | ||
namespace Foo\Bar { | ||
class Baz implements BamAwareInterface { | ||
public $bam; | ||
public function setBam(Bam $bam){ | ||
$this->bam = $bam; | ||
} | ||
} | ||
class Bam { | ||
} | ||
interface BamAwareInterface | ||
{ | ||
public function setBam(Bam $bam); | ||
} | ||
} | ||
namespace { | ||
include 'zf2bootstrap.php'; | ||
$di = new Zend\Di\Di; | ||
$baz = $di->get('Foo\Bar\Baz'); | ||
} | ||
]]></programlisting> | ||
|
||
|
||
</section> | ||
|
||
|
||
<section xml:id="zend.di.zend.di.debugging-and-complex-use-cases.complex-use-cases.setter-injection-with-class-definition"> | ||
<info><title>Setter Injection with Class Definition</title></info> | ||
|
||
<programlisting language="php"><![CDATA[ | ||
namespace Foo\Bar { | ||
class Baz { | ||
public $bam; | ||
public function setBam(Bam $bam){ | ||
$this->bam = $bam; | ||
} | ||
} | ||
class Bam { | ||
} | ||
} | ||
namespace { | ||
$di = new Zend\Di\Di; | ||
$di->configure(new Zend\Di\Configuration(array( | ||
'definition' => array( | ||
'class' => array( | ||
'Foo\Bar\Baz' => array( | ||
'setBam' => array('required' => true) | ||
) | ||
) | ||
) | ||
))); | ||
$baz = $di->get('Foo\Bar\Baz'); | ||
} | ||
]]></programlisting> | ||
|
||
</section> | ||
|
||
|
||
<section xml:id="zend.di.zend.di.debugging-and-complex-use-cases.complex-use-cases.multiple-injections"> | ||
<info><title>Multiple Injections To A Single Injection Point</title></info> | ||
|
||
|
||
<programlisting language="php"><![CDATA[ | ||
namespace Application { | ||
class Page { | ||
public $blocks; | ||
public function addBlock(Block $block){ | ||
$this->blocks[] = $block; | ||
} | ||
} | ||
interface Block { | ||
} | ||
} | ||
namespace MyModule { | ||
class BlockOne implements \Application\Block {} | ||
class BlockTwo implements \Application\Block {} | ||
} | ||
namespace { | ||
include 'zf2bootstrap.php'; | ||
$di = new Zend\Di\Di; | ||
$di->configure(new Zend\Di\Configuration(array( | ||
'definition' => array( | ||
'class' => array( | ||
'Application\Page' => array( | ||
'addBlock' => array( | ||
'block' => array('type' => 'Application\Block', 'required' => true) | ||
) | ||
) | ||
) | ||
), | ||
'instance' => array( | ||
'Application\Page' => array( | ||
'injections' => array( | ||
'MyModule\BlockOne', | ||
'MyModule\BlockTwo' | ||
) | ||
) | ||
) | ||
))); | ||
$page = $di->get('Application\Page'); | ||
} | ||
]]></programlisting> | ||
|
||
</section> | ||
|
||
</section> | ||
|
||
</section> |
Oops, something went wrong.