lib/Registry/Registry.php
public function getService($name = null)
    {
        $name = $name ?: $this->defaultService;

        if (!$name) {
            throw new \RuntimeException(sprintf(
                'You must configure a default %s service, registered %s services: "%s"',
                $this->serviceType, $this->serviceType,
                implode('", "', array_keys($this->services))
            ));
        }

        if (isset($this->services[$name])) {
            return $this->services[$name];
        }

        $this->assertServiceExists($name);
        $this->services[$name] = $this->container->get($this->serviceMap[$name]);

        return $this->services[$name];
    }
public function getService($name = null)
    {
        $name = $name ?: $this->defaultService;

        if (!$name) {
            throw new \RuntimeException(sprintf(
                'You must configure a default %s service, registered %s services: "%s"',
                $this->serviceType, $this->serviceType,
                implode('", "', array_keys($this->services))
            ));
        }

        if (isset($this->services[$name])) {
            return $this->services[$name];
        }

        $this->assertServiceExists($name);
        $this->services[$name] = $this->container->get($this->serviceMap[$name]);

        return $this->services[$name];
    }
public function getService ( $ name = null ) { $ name = $ name ? : $ this -> defaultService ; if ( ! $ name ) { throw new \ RuntimeException ( sprintf ( 'You must configure a default %s service, registered %s services: "%s"' , $ this -> serviceType , $ this -> serviceType , implode ( '", "' , array_keys ( $ this -> services ) ) ) ) ; } if ( isset ( $ this -> services [ $ name ] ) ) { return $ this -> services [ $ name ] ; } $ this -> assertServiceExists ( $ name ) ; $ this -> services [ $ name ] = $ this -> container -> get ( $ this -> serviceMap [ $ name ] ) ; return $ this -> services [ $ name ] ; }
Return the named service, lazily creating it from the container
if it has not yet been accessed.

@param string $name

@return object
Return the named service lazily creating it from the container if it has not yet been accessed .