private function findServiceClassName($services, $serviceName)
    {
        $candidates = array_filter(array_keys($services), function ($service) use ($serviceName) {
            $service = str_replace(array('/', '*', '-'), array('\\/', '.*', '\\-'), $service);
            return preg_match('/^' . $service . '$/', $serviceName);
        });
        if (count($candidates) > 0) {
            $prefix = preg_replace('/\*$/', '', current($candidates));
            $info = $services[current($candidates)];
            if (strpos($info, 'file:') === 0) {
                $appFile = $this->environment->getBootstrap()->getAppRoot() . '/' . str_replace('file:', '', $info);
                $config = json_decode(file_get_contents($appFile), true);
                return $this->findServiceClassName($config['services'], str_replace($prefix, '', $serviceName));
            } else {
                return $info;
            }
        }
        throw new \Exception("Unknown service: '{$serviceName}'");
    }
private function findServiceClassName($services, $serviceName)
    {
        $candidates = array_filter(array_keys($services), function ($service) use ($serviceName) {
            $service = str_replace(array('/', '*', '-'), array('\\/', '.*', '\\-'), $service);
            return preg_match('/^' . $service . '$/', $serviceName);
        });
        if (count($candidates) > 0) {
            $prefix = preg_replace('/\*$/', '', current($candidates));
            $info = $services[current($candidates)];
            if (strpos($info, 'file:') === 0) {
                $appFile = $this->environment->getBootstrap()->getAppRoot() . '/' . str_replace('file:', '', $info);
                $config = json_decode(file_get_contents($appFile), true);
                return $this->findServiceClassName($config['services'], str_replace($prefix, '', $serviceName));
            } else {
                return $info;
            }
        }
        throw new \Exception("Unknown service: '{$serviceName}'");
    }
private function findServiceClassName ( $ services , $ serviceName ) { $ candidates = array_filter ( array_keys ( $ services ) , function ( $ service ) use ( $ serviceName ) { $ service = str_replace ( array ( '/' , '*' , '-' ) , array ( '\\/' , '.*' , '\\-' ) , $ service ) ; return preg_match ( '/^' . $ service . '$/' , $ serviceName ) ; } ) ; if ( count ( $ candidates ) > 0 ) { $ prefix = preg_replace ( '/\*$/' , '' , current ( $ candidates ) ) ; $ info = $ services [ current ( $ candidates ) ] ; if ( strpos ( $ info , 'file:' ) === 0 ) { $ appFile = $ this -> environment -> getBootstrap ( ) -> getAppRoot ( ) . '/' . str_replace ( 'file:' , '' , $ info ) ; $ config = json_decode ( file_get_contents ( $ appFile ) , true ) ; return $ this -> findServiceClassName ( $ config [ 'services' ] , str_replace ( $ prefix , '' , $ serviceName ) ) ; } else { return $ info ; } } throw new \ Exception ( "Unknown service: '{$serviceName}'" ) ; }
Searches the services list for a matching service specification and returns the corresponding class name.

@param  mixed[] $services    list of services
@param  string  $serviceName name of requested service

@throws \Exception if no matching service was found
@return string     class name
Searches the services list for a matching service specification and returns the corresponding class name .