Created
February 1, 2012 15:35
-
-
Save flavius/1717559 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<?php | |
namespace demo; | |
class Bar { | |
protected $options; | |
public function __construct($options = null) { | |
$this->options = $options; | |
} | |
} |
This file contains hidden or 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
<?php | |
namespace demo; | |
class Foo { | |
protected $resolver; | |
public function __construct() { | |
var_dump(func_get_args()); | |
} | |
public function setResolver($resolver /*, $options = null /**/) { | |
$this->resolver = $resolver; | |
} | |
} |
This file contains hidden or 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
<?php | |
require_once '/home/flav/projects/checkouts/zf2/library/Zend/Loader/AutoloaderFactory.php'; | |
\Zend\Loader\AutoloaderFactory::factory(array('Zend\Loader\StandardAutoloader' => array( | |
'namespaces' => array( | |
'demo' => 'demo/', | |
) | |
))); | |
$config = array( | |
'instance' => array( | |
'alias' => array( | |
'view' => 'demo\Foo', | |
), | |
'demo\Foo' => array( | |
'parameters' => array( | |
'resolver' => 'demo\Bar', | |
'options' => array( | |
'script_paths' => array('application' => __DIR__ . '/views'), | |
), | |
) | |
), | |
) | |
); | |
$c = new Zend\Config\Config($config); | |
$di = new \Zend\Di\Di; | |
$di->instanceManager()->addTypePreference('Zend\Di\Locator', $di); | |
$config = new \Zend\Di\Configuration($c); | |
$config->configure($di); | |
$foo = $di->get('view'); | |
var_dump($foo); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment