Skip to content

Commit

Permalink
Updated examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Ralph Schindler committed Nov 2, 2011
1 parent 0bc9424 commit 0c2decd
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
3 changes: 2 additions & 1 deletion example-11.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

include 'Zend_Di-2.0.0beta1.phar';
// bootstrap
include 'zf2bootstrap' . ((stream_resolve_include_path('zf2bootstrap.php')) ? '.php' : '.dist.php');

// must register autoloader
spl_autoload_register(function ($class) {
Expand Down
5 changes: 3 additions & 2 deletions example-12.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

include 'Zend_Di-2.0.0beta1.phar';
// bootstrap
include 'zf2bootstrap' . ((stream_resolve_include_path('zf2bootstrap.php')) ? '.php' : '.dist.php');

// must register autoloader
spl_autoload_register(function ($class) {
Expand All @@ -21,7 +22,7 @@
$di = new Zend\Di\Di($definitions);

$baz = $di->get('Foo\Bar\Baz');
var_dump($baz);

// expression to test
$works = ($baz->bam instanceof Foo\Bar\Bam);

Expand Down
16 changes: 15 additions & 1 deletion example-14.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,24 @@ class Finder {
include 'zf2bootstrap' . ((stream_resolve_include_path('zf2bootstrap.php')) ? '.php' : '.dist.php');

$di = new Zend\Di\Di;

$di->instanceManager()->setParameters(
'MovieApp\Lister',
array(
'MovieApp\Lister::setFinderA:0' => new MovieApp\Finder,
'MovieApp\Lister::setFinderB:0' => function () {
return new MovieApp\Finder;
}
)
);

$lister = $di->get('MovieApp\Lister');

// expression to test
$works = ($lister->finder instanceof MovieApp\Finder);
$works = ($lister->finderA instanceof MovieApp\Finder
&& $lister->finderB instanceof MovieApp\Finder
&& $lister->finderA !== $lister->finderB
);

// display result
echo (($works) ? 'It works!' : 'It DOES NOT work!');
Expand Down
2 changes: 1 addition & 1 deletion example-15.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class DriverTwo implements \System\Driver {}
$mapper->drivers[0][0] instanceof DifferentNs\DriverOne
&& $mapper->drivers[1][0] instanceof DifferentNs\DriverTwo
);
var_dump($mapper);

// display result
echo (($works) ? 'It works!' : 'It DOES NOT work!');
}

0 comments on commit 0c2decd

Please sign in to comment.