Skip to content

Instantly share code, notes, and snippets.

@Schlaefer
Last active August 29, 2015 14:20
Show Gist options
  • Save Schlaefer/e2e25eb3eb8b1b1ae541 to your computer and use it in GitHub Desktop.
Save Schlaefer/e2e25eb3eb8b1b1ae541 to your computer and use it in GitHub Desktop.
<?php
class Dic {
/**
* @var \Aura\Di\Container;
*/
static protected $_DIC;
public static function initialize() {
$dic = new \Aura\Di\Container(new \Aura\Di\Factory);
// do dependency setup:
$dic->params['ExampleNeedsService']['foo'] = $dic->lazyGet('foo_service');
// …
self::$_DIC = $dic;
}
public static function set($key, $object) {
self::$_DIC->set($key, $object);
}
public static function get($key) {
return self::$_DIC->get($key);
}
public static function newInstance($key, array $params = [], array $setter = []) {
return self::$_DIC->newInstance($key, $params, $setter);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment