获取服务url配置
@param $service
@return array
@throws ErrorException
186996
protected function getServiceUrls($service)
    {
        if (!$this->_config) {
            $httpClient = new HttpClient();
            $httpClient->transport = CurlTransport::class;
            $requests = [];
            foreach ($this->discoverUrls as $discoverUrl) {
                $requests[] = $httpClient->get($discoverUrl);
            }
            $responses = $httpClient->batchSend($requests);

            $list = [];
            foreach ($responses as $response) {
                foreach ($response->data as $name => $url) {
                    $list[$name][] = $url;
                }
            }

            $this->_config = $list;
        }

        if (isset($this->_config[$service]) && $this->_config[$service]) {
            return $this->_config[$service];
        } else {
            throw new ErrorException('不存在该服务，请检查服务中心');
        }
    }
711167
private function getCallbackReturnList($service, $method, $args)
    {
        if ($args != null) {
            $parsedArgs = json_decode($args, true);
            if (!is_array($parsedArgs)) {
                $parsedArgs = explode(',', $args);
            }
        } else {
            $parsedArgs = null;
        }
        $serviceInstance = \Drupal::service($service);

        if (!method_exists($serviceInstance, $method)) {
            throw new \Symfony\Component\DependencyInjection\Exception\BadMethodCallException($this->trans('commands.debug.container.errors.method-not-exists'));

            return $serviceDetail;
        }
        $serviceDetail[] = [
            $this->addGreenTranslationWrapper('commands.debug.container.messages.service'),
            $this->addWrapper($service),
        ];
        $serviceDetail[] = [
            $this->addGreenTranslationWrapper('commands.debug.container.messages.class'),
            $this->addWrapper(get_class($serviceInstance)),
        ];
        $methods = [$method];
        $this->extendArgumentList($serviceInstance, $methods);
        $serviceDetail[] = [
            $this->addGreenTranslationWrapper('commands.debug.container.messages.method'),
            $this->addWrapper($methods[0]),
        ];
        if ($parsedArgs) {
            $serviceDetail[] = [
                $this->addGreenTranslationWrapper('commands.debug.container.messages.arguments'),
                $this->addWrapper(json_encode($parsedArgs, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)),
            ];
        }
        $return = call_user_func_array([$serviceInstance,$method], $parsedArgs);
        $serviceDetail[] = [
            $this->addGreenTranslationWrapper('commands.debug.container.messages.return'),
            $this->addWrapper(json_encode($return, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)),
        ];
        return $serviceDetail;
    }
344583
public function getURLService()
    {
        if ($this->urlService !== null) {
            return $this->urlService;
        }

        $this->urlService = new URLService(
            $this,
            $this->persistenceHandler->urlHandler()
        );

        return $this->urlService;
    }
1314454
public static function service(string $service)
    {
        if (!array_key_exists($service, self::$available_services)) {
            throw (new ServiceNotFoundException(sprintf(
                '"%s" is not registered as a service.',
                $service
            )))->setServiceName($service);
        }

        $service_class = static::$available_services[$service];

        $config = static::$config['services'][$service] ?? null;

        if (is_null($config)) {
            throw (new ServiceConfigurationNotFoundException(sprintf(
                '"%s" configuration not found.',
                $service
            )))->setServiceName($service);
        }

        return $service_class::configure($config);
    }
168031
public function addLinksFrom(Service $service) {
	    $links = $service->getLinks();
	    foreach($links as $name => $link) {
	        if (is_numeric($name)) {
                $this->addLink($link);
            } else {
                $this->addLink($link, $name);
            }
        }

        $externalLinks = $service->getExternalLinks();
	    foreach($externalLinks as $name => $link) {
	        if (is_numeric($name)) {
                $this->addExternalLink($link);
            } else {
                $this->addExternalLink($link, $name);
            }
        }

	}
840133
public function getService($service)
    {
        foreach ($this->queue as $extension) {
            $new = call_user_func($extension, $service, $this->container);

            if ($new) {
                $service = $new;
            }
        }

        return $service;
    }
374571
public function get($id)
    {
        if (isset($this->services[$id]) && $this->shareds[$id]) {
            return $this->services[$id];
        }
        
        if (!$this->has($id)) {
            throw new Exception('not exists id: ' . $id);
        }

        // 实例创建的参数
        $args = $this->params[$id];

        $definition = $this->definitions[$id];
        if ($definition instanceof \Closure || (is_string($definition) && function_exists($definition))) {
            // 执行闭包/函数
            $object = $definition(...$args);
        } elseif (is_string($definition)) {
            // 创建类实例
            $object = new $definition(...$args);
        } else {
            throw new Exception('definition error: ' . $id);
        }
        
        if ($this->shareds[$id]) {
            $this->services[$id] = $object;
        }
        
        return $object;
    }
1018287
private function status($service) {
        $rtn = $this->sendCommand('status', ['service' => $service]);
        if ($rtn) {
            $status = $this->getStatus($rtn['status']);
            if ($service) {
                if (isset($rtn['detail']) && $rtn['detail']) {
                    foreach ($rtn['detail'] as $item => $v) {
                        $this->output($this->cell($item, 20), false);
                        if ($item == 'pids') {
                            $this->output(implode(',', array_keys($v)));
                        } else if ($item == 'status') {
                            $this->output($this->getStatus($v));
                        } else if ($item == 'env') {
                            $this->output($this->cell([['key', 20], ['value', 6]]));
                            foreach ($v as $vk => $vv) {
                                $this->output($this->cell([['', 20], [$vk, 20]]) . $vv);
                            }
                        } else if (is_array($v)) {
                            $this->output(json_encode($v));
                        } else {
                            $this->output($v);
                        }
                    }
                } else {
                    $this->output($service . ' is ' . $status);
                }
            } else {
                $services = $rtn['services'];
                $this->output($this->cell([
                    ['Service', 20],
                    ['Type', 16],
                    ['Worker', 10],
                    ['Status', 20],
                    ['Message', 44]
                ]));
                $this->output($this->cell('-', 80, '-'));
                foreach ($services as $id => $ser) {
                    $this->output($this->cell([
                        [$id, 20],
                        [$ser['type'], 16],
                        [isset($ser['worker']) ? $ser['worker'] : 1, 10],
                        [$this->getStatus($ser['status']), 20],
                        [isset($ser['msg']) ? $ser['msg'] : '', 44]
                    ]));
                }
            }
        } else {
            $this->error('Cannot read status data');
        }
    }
1371159
public function services(string $service): array
    {
        if (empty($this->services[$service])) {
            $this->services = $this->all();
        }

        if (! empty($this->services[$service])) {
            return $this->services[$service];
        }

        throw new RangeException("The service[{$service}] not found");
    }
676960
protected function transformCorreiosService(array $service)
    {
        $error = [];

        if ($service['Erro'] != 0) {
            $error = [
                'code' => $service['Erro'],
                'message' => $service['MsgErro'],
            ];
        }

        return [
            'name' => $this->friendlyServiceName($service['Codigo']),
            'code' => $service['Codigo'],
            'price' => floatval(str_replace(',', '.', $service['Valor'])),
            'deadline' => intval($service['PrazoEntrega']),
            'error' => $error,
        ];
    }
832352
public function get($service)
    {
        // Is the service active?
        if (isset($this->active[$service])) {
            if ($this->loaded[$service]['singleton']) {
                return $this->active[$service];
            } else {
                return $this->load($service);
            }
        } elseif (isset($this->loaded[$service])) {
            // Is the service loaded?
            return $this->load($service);
        }

        $message  = "CDI the service accessed '$service' is not loaded in the DI-container.";
        $services = $this->getServices();
        natcasesort($services);
        $services = implode("\n", $services);
        $message .= " Loaded services are: <pre>$services</pre>";
        
        throw new \Exception($message);
    }
13285
private function getServiceSchema($service)
    {
        $operation = $service->getOperation();
        $schema = new \stdClass();
        switch (strtolower($service->getMethod())) {
            case "post":
            case "put":
                try {
                    $parameters = $operation->getDocumentObjectProperty('parameters', Parameter\Body::class, true);
                } catch (MissingDocumentPropertyException $e) {
                    // request has no params
                    break;
                }
                foreach ($parameters as $parameter) {
                    /**
                     * there is no schema information available, if $action->parameters[0]->in != 'body'
                     *
                     * @link http://swagger.io/specification/#parameterObject
                     */
                    if ($parameter instanceof Parameter\Body && $parameter->getIn() === 'body') {
                        $ref = $parameter->getDocumentObjectProperty('schema', Reference::class)->getDocument();
                        $schema = $this->resolveSchema($ref);
                        break;
                    }
                }
                break;
            case "get":
                try {
                    $response = $operation->getResponses()->getHttpStatusCode(200);
                } catch (MissingDocumentPropertyException $e) {
                    // no response with status code 200 is defined
                    break;
                }
                $schema = $this->resolveSchema($response->getSchema()->getDocument());
                break;
        }

        return $schema;
    }
271958
private function getServiceTicket($service)
    {


        try {
            $response = $this->guzzleClient->request(
                'POST',
                $this->tgtLocation,
                [
                    'verify' => $this->verifySSL,
                    'form_params' => [
                        'service' => $service
                    ]
                ]
            );
            return (string) $response->getBody();
        } catch (ClientException $e) {
            // Bad TGT - login again
            if ($e->getCode() == 404) {
                // Force authentication and save the TGT
                $this->login($this->tgtStorageLocation, true);
                return $this->getServiceTicket($service);
                // Unsupported Media Type
            } elseif ($e->getCode() == 415) {
                return false;
            } else {
                throw new \Exception($e->getMessage(), $e->getCode());
            }
        } catch (\Exception $e) {
            throw new \Exception($e->getMessage(), $e->getCode());
        }
    }
138532
protected function getService($service)
    {
        if (!isset($this->app[$service])) {
            throw new \Exception('O serviço '.$service.' não foi registrado na aplicação!');
        }

        return $this->app[$service];
    }
217574
public function getServiceUrl($resource = '', $params = [])
    {
        $format = $resource === '' ? '' : '.json';
        $url = $this->serviceScheme . '://' . $this->serviceDomain . '/'
            . $resource . $format;

        if ($params) {
            $url .= '?' . http_build_query($params);
        }

        return $url;
    }
604558
private function loadMethodLevelAnnotations(object $service): AnnotationCollection
    {
        return $this->annotationReader
            ->extract(\get_class($service))
            ->filter(
                static function(Annotation $annotation): ?Annotation
                {
                    if ($annotation->annotationObject instanceof ServicesAnnotationsMarker)
                    {
                        return $annotation;
                    }

                    return null;
                }
            )
            ->methodLevelAnnotations();
    }
1337499
public function propagate($service)
    {
        if(is_object($service) &&  ($service instanceof ServiceLocatorAwareInterface)){
            $service->setServiceLocator($this);
        }
        return $service;
    }