src/Discovery/Repository/ServiceRepository.php
public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
    {
        $resource = 'http://'.$this->host.static::RESOURCE_LIST;

        try {
            $response = $this->client->request('GET', $resource, [
                'headers' => [
                    'X-Consul-Token' => $this->token
                ]
            ]);
        } catch (ClientException $exception) {
            return null;
        }

        $body = (string) $response->getBody();
        $objects = \GuzzleHttp\json_decode($body);
        $models = new ArrayCollection;

        if ($objects) {
            foreach ($objects as $id => $tags) {
                if (array_key_exists('id', $criteria) && !preg_match($criteria['id'], $id)) {
                    continue;
                }

                if (array_key_exists('tag', $criteria) && !in_array($criteria['tag'], $tags)) {
                    continue;
                }

                $response = $this->client->request('GET', 'http://'.$this->host.'/v1/catalog/service/'.$id, [
                    'headers' => [
                        'X-Consul-Token' => $this->token
                    ]
                ]);
                $body = (string) $response->getBody();
                $objects = \GuzzleHttp\json_decode($body);

                if (!$objects) {
                    continue;
                }

                $models->add($this->toModel($objects[0]));
            }
        }

        return $models;
    }
public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
    {
        $resource = 'http://'.$this->host.static::RESOURCE_LIST;

        try {
            $response = $this->client->request('GET', $resource, [
                'headers' => [
                    'X-Consul-Token' => $this->token
                ]
            ]);
        } catch (ClientException $exception) {
            return null;
        }

        $body = (string) $response->getBody();
        $objects = \GuzzleHttp\json_decode($body);
        $models = new ArrayCollection;

        if ($objects) {
            foreach ($objects as $id => $tags) {
                if (array_key_exists('id', $criteria) && !preg_match($criteria['id'], $id)) {
                    continue;
                }

                if (array_key_exists('tag', $criteria) && !in_array($criteria['tag'], $tags)) {
                    continue;
                }

                $response = $this->client->request('GET', 'http://'.$this->host.'/v1/catalog/service/'.$id, [
                    'headers' => [
                        'X-Consul-Token' => $this->token
                    ]
                ]);
                $body = (string) $response->getBody();
                $objects = \GuzzleHttp\json_decode($body);

                if (!$objects) {
                    continue;
                }

                $models->add($this->toModel($objects[0]));
            }
        }

        return $models;
    }
{@inheritdoc}