-
Notifications
You must be signed in to change notification settings - Fork 22
/
example-20.php
37 lines (30 loc) · 884 Bytes
/
example-20.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
namespace MovieApp {
class Lister {
public $finder;
public function setFinder(FinderInterface $finder){
$this->finder = $finder;
}
}
class DbFinder implements FinderInterface{
}
interface FinderInterface {
}
}
namespace {
// bootstrap
include 'zf2bootstrap' . ((stream_resolve_include_path('zf2bootstrap.php')) ? '.php' : '.dist.php');
$di = new Zend\Di\Di;
$di->configure(new Zend\Di\Configuration(array(
'instance' => array(
'preferences' => array(
'MovieApp\FinderInterface' => 'MovieApp\DbFinder'
)
)
)));
$lister = $di->get('MovieApp\Lister');
// expression to test
$works = ($lister->finder instanceof MovieApp\DbFinder);
// display result
echo (($works) ? 'It works!' : 'It DOES NOT work!') . PHP_EOL;
}