getService() public method

Return the named service, lazily creating it from the container if it has not yet been accessed.
public getService ( string $name = null ) : object
$name string
return object
Esempio n. 1
0
 /**
  * It should throw an exception if no argument given to get() and no default is defined.
  *
  * @expectedException RuntimeException
  * @expectedExceptionMessage You must configure a default test service, registered test services: "foo"
  */
 public function testDefaultGetNoDefault()
 {
     $registry = new Registry('test', $this->container->reveal());
     $registry->setService('foo', 'bar');
     $this->assertEquals($registry->getService(), 'bar');
 }