forked from ralphschindler/Zend_DI-Examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample-09.php
More file actions
32 lines (26 loc) · 788 Bytes
/
example-09.php
File metadata and controls
32 lines (26 loc) · 788 Bytes
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
<?php
namespace MovieApp {
use Zend\Di\Definition\Annotation as Di;
class Lister {
public $finder;
/**
* @Di\Inject()
*/
public function setFinder(Finder $finder){
$this->finder = $finder;
}
}
class Finder {
}
}
namespace {
// bootstrap
include 'zf2bootstrap' . ((stream_resolve_include_path('zf2bootstrap.php')) ? '.php' : '.dist.php');
$di = new Zend\Di\Di;
$di->definitions()->getDefinitionForClass('MovieApp\Lister')->getIntrospectionStrategy()->setUseAnnotations(true);
$lister = $di->get('MovieApp\Lister');
// expression to test
$works = ($lister->finder instanceof MovieApp\Finder);
// display result
echo (($works) ? 'It works!' : 'It DOES NOT work!');
}