Liip\RMT\Context::getService PHP Method

getService() public method

public getService ( $id )
    public function getService($id)
    {
        if (!isset($this->services[$id])) {
            throw new \InvalidArgumentException("There is no service defined with id [{$id}]");
        }
        if (is_array($this->services[$id])) {
            $this->services[$id] = $this->instanciateObject($this->services[$id]);
        }
        return $this->services[$id];
    }

Usage Example

Example #1
0
 /**
  * @expectedException InvalidArgumentException
  * @expectedExceptionMessage There is no service defined with id [abc]
  */
 public function _testGetServiceWithoutSet()
 {
     $this->context->getService('abc');
 }