factory() public method

Registers a {@link Factory} or closure to be invoked on the first lookup
public factory ( $key, $factory )
示例#1
0
 public function testRegisteringAClosureAsAFactory()
 {
     $registry = new Registry();
     $registry->factory('my_key', function () {
         return (object) array('test' => 'blargh');
     });
     $this->assertTrue($registry->isRegistered('my_key'));
     $this->assertEquals($registry->lookup('my_key')->test, 'blargh');
 }