Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
Added includes
Browse files Browse the repository at this point in the history
  • Loading branch information
GeeH committed Nov 5, 2015
1 parent f50e5ec commit 45b9609
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion doc/book/zend.di.configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ definition setup and instance manager setup.

The definition section expects the following information expressed as a PHP array:

``` sourceCode
```php
$config = array(
'definition' => array(
'compiler' => array(/* @todo compiler information */),
Expand Down
10 changes: 5 additions & 5 deletions doc/book/zend.di.debugging-and-complex-use-cases.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@ a Di instance.

The easiest way is to do the following:

``` sourceCode
```php
Zend\Di\Display\Console::export($di);
```

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:

``` sourceCode
```php
Zend\Di\Display\Console::export($di, array('A\ClassIWantTo\GetTheDefinitionFor'));
```

## Complex Use Cases

### Interface Injection

``` sourceCode
```php
namespace Foo\Bar {
class Baz implements BamAwareInterface
{
Expand Down Expand Up @@ -51,7 +51,7 @@ namespace {

### Setter Injection with Class Definition

``` sourceCode
```php
namespace Foo\Bar {
class Baz
{
Expand Down Expand Up @@ -83,7 +83,7 @@ namespace {

### Multiple Injections To A Single Injection Point

``` sourceCode
```php
namespace Application {
class Page
{
Expand Down
8 changes: 4 additions & 4 deletions doc/book/zend.di.definitions.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Zend\\Di\\Definition\\RuntimeDefinition will have determining the structure of y

This is what the constructor of a RuntimeDefinition looks like:

``` sourceCode
```php
public function __construct(IntrospectionStrategy $introspectionStrategy = null, array
$explicitClasses = null)
{
Expand All @@ -51,7 +51,7 @@ is registered by default, this is a list of patterns.

The constructor for the IntrospectionStrategy looks like this:

``` sourceCode
```php
public function __construct(AnnotationManager $annotationManager = null)
{
$this->annotationManager = ($annotationManager) ?: $this->createDefaultAnnotationManager();
Expand Down Expand Up @@ -80,7 +80,7 @@ scanning the actual code.
For example, let's assume we want to create a script that will create definitions for some of our
library code:

``` sourceCode
```php
// in "package name" format
$components = array(
'My_MovieApp',
Expand All @@ -102,7 +102,7 @@ foreach ($components as $component) {
This will create a couple of files that will return an array of the definition for that class. To
utilize this in an application, the following code will suffice:

``` sourceCode
```php
protected function setupDi(Application $app)
{
$definitionList = new DefinitionList(array(
Expand Down
10 changes: 5 additions & 5 deletions doc/book/zend.di.instance-manager.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ parameter, and is a situation best avoided.

Our movie finder example can be further used to explain these concepts:

``` sourceCode
```php
namespace MyLibrary
{
class DbAdapter
Expand Down Expand Up @@ -66,7 +66,7 @@ $di->get('MyMovieApp\\MovieLister') to throw an exception.

The following ways of using parameters are available:

``` sourceCode
```php
// setting instance configuration into the instance manager
$di->instanceManager()->setParameters('MyLibrary\DbAdapter', array(
'username' => 'myusername',
Expand Down Expand Up @@ -95,7 +95,7 @@ $movieLister = $di->get('MyMovieApp\MovieLister', array(
In some cases, you might be using interfaces as type hints as opposed to concrete types. Lets assume
the movie example was modified in the following way:

``` sourceCode
```php
namespace MyMovieApp
{
interface MovieFinderInterface
Expand Down Expand Up @@ -132,7 +132,7 @@ manager.

To give this information to the instance manager, see the following code example:

``` sourceCode
```php
$di->instanceManager()->addTypePreference('MyMovieApp\MovieFinderInterface',
'MyMovieApp\GenericMovieFinder');
// assuming all instance config for username, password is setup
Expand All @@ -153,7 +153,7 @@ DbAdapters, one will be for read-only operations, the other will be for read-wri
> ## Note
Aliases can also have parameters registered at alias time

``` sourceCode
```php
// assume the MovieLister example of code from the QuickStart

$im = $di->instanceManager();
Expand Down
2 changes: 1 addition & 1 deletion doc/book/zend.di.introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Dependency Injection (here-in called DI) is a concept that has been talked about
over the web. Simply put, we'll explain the act of injecting dependencies simply with this below
code:

``` sourceCode
```php
$b = new MovieLister(new MovieFinder());
```

Expand Down
10 changes: 5 additions & 5 deletions doc/book/zend.di.quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ the other sections of the manual is suggested.
Assume for a moment, you have the following code as part of your application that you feel is a good
candidate for being managed by a DiC, after all, you are already injecting all your dependencies:

``` sourceCode
```php
namespace MyLibrary
{
class DbAdapter
Expand Down Expand Up @@ -46,7 +46,7 @@ namespace MyMovieApp

With the above code, you find yourself writing the following to wire and utilize this code:

``` sourceCode
```php
// $config object is assumed

$dbAdapter = new MyLibrary\DbAdapter($config->username, $config->password);
Expand All @@ -64,7 +64,7 @@ swap out one of these dependencies on a wholesale scale.
Since this example of code already practices good dependency injection, with constructor injection,
it is a great candidate for using Zend\\Di. The usage is as simple as:

``` sourceCode
```php
// inside a bootstrap somewhere
$di = new Zend\Di\Di();
$di->instanceManager()->setParameters('MyLibrary\DbAdapter', array(
Expand All @@ -84,7 +84,7 @@ that Zend\\Di\\Di is constructed with a DefinitionList seeded with a RuntimeDefi
Reflection) and an empty instance manager and no configuration. Here is the Zend\\Di\\Di
constructor:

``` sourceCode
```php
public function __construct(DefinitionList $definitions = null, InstanceManager $instanceManager =
null, Configuration $config = null)
{
Expand All @@ -107,7 +107,7 @@ second parameter, respectively, of the constructor consuming these named paramet
If you were to want to pass in the username and password at call time, this is achieved by passing
them as the second argument of get():

``` sourceCode
```php
// inside each controller
$di = new Zend\Di\Di();
$movieLister = $di->get('MyMovieApp\MovieLister', array(
Expand Down

0 comments on commit 45b9609

Please sign in to comment.