Created
December 5, 2014 15:05
-
-
Save rianorie/40e241aa74390309d764 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 | |
class MyLib extends \Phalcon\Di\InjectionAware | |
{ | |
private $filename; | |
public function __construct(\Phalcon\DiInterface $di) | |
{ | |
$this->setDI($di); | |
$this->filename = $this->getDI()->get('config')->daemon->hb_filename; | |
} | |
} | |
// ------------------------ | |
$di->set('mylib', function() use ($di) { | |
return new MyLib($di); | |
}); | |
// ------------ | |
$di->getShared('mylib'); // shared version of the class, for all intents and purposes a singleton. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment