Skip to content

Instantly share code, notes, and snippets.

@flavius
Created February 1, 2012 15:35
Show Gist options
  • Save flavius/1717559 to your computer and use it in GitHub Desktop.
Save flavius/1717559 to your computer and use it in GitHub Desktop.
<?php
namespace demo;
class Bar {
protected $options;
public function __construct($options = null) {
$this->options = $options;
}
}
<?php
namespace demo;
class Foo {
protected $resolver;
public function __construct() {
var_dump(func_get_args());
}
public function setResolver($resolver /*, $options = null /**/) {
$this->resolver = $resolver;
}
}
<?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