src/GetServiceCapableCachingTrait.php
protected function _getService($key)
    {
        $cache             = $this->_getServiceCache();
        $notFoundException = null;

        try {
            return $cache->get($key, function ($key) use (&$notFoundException) {
                try {
                    $definition = $this->_get($key);
                } catch (NotFoundExceptionInterface $e) {
                    $notFoundException = $e;
                    throw $e;
                }

                 return $this->_resolveDefinition($definition);
            });
        } catch (RootException $e) {
            if ($notFoundException instanceof NotFoundExceptionInterface) {
                throw $notFoundException;
            }

            throw $this->_throwContainerException($this->__('Could not retrieve service'), null, $e, true);
        }
    }
protected function _getService($key)
    {
        $cache             = $this->_getServiceCache();
        $notFoundException = null;

        try {
            return $cache->get($key, function ($key) use (&$notFoundException) {
                try {
                    $definition = $this->_get($key);
                } catch (NotFoundExceptionInterface $e) {
                    $notFoundException = $e;
                    throw $e;
                }

                 return $this->_resolveDefinition($definition);
            });
        } catch (RootException $e) {
            if ($notFoundException instanceof NotFoundExceptionInterface) {
                throw $notFoundException;
            }

            throw $this->_throwContainerException($this->__('Could not retrieve service'), null, $e, true);
        }
    }
protected function _getService ( $ key ) { $ cache = $ this -> _getServiceCache ( ) ; $ notFoundException = null ; try { return $ cache -> get ( $ key , function ( $ key ) use ( & $ notFoundException ) { try { $ definition = $ this -> _get ( $ key ) ; } catch ( NotFoundExceptionInterface $ e ) { $ notFoundException = $ e ; throw $ e ; } return $ this -> _resolveDefinition ( $ definition ) ; } ) ; } catch ( RootException $ e ) { if ( $ notFoundException instanceof NotFoundExceptionInterface ) { throw $ notFoundException ; } throw $ this -> _throwContainerException ( $ this -> __ ( 'Could not retrieve service' ) , null , $ e , true ) ; } }
Retrieves a service by key.

@since [*next-version*]

@param string|int|float|bool|Stringable $key The key, for which to get the service.

@throw NotFoundExceptionInterface If no service or definition found for key.
@throw ContainerExceptionInterface If service or service definition could not be retrieved.

@return mixed The corresponding service.
Retrieves a service by key .