public function addServiceCatalog($type, $name, array $endpoints)
    {
        if (!array_key_exists($type, $this->catalogs)) {
            $this->catalogs[$type] = [];
        }

        // check if endpoints config is correct
        foreach ($endpoints as $index => $endpoint) {
            if (!is_array($endpoint)) {
                throw new TokenException('Expecting an array for an endpoint');
            }

            $endpoints[$index] = array_change_key_case($endpoint, CASE_LOWER);

            if (!isset($endpoints[$index]['publicurl']) && !isset($endpoints[$index]['adminurl'])) {
                throw new TokenException(
                    sprintf('An endpoint must have either a "publicurl" or "adminurl" key, got %s', json_encode($endpoint))
                );
            }
        }

        $this->catalogs[$type][$name] = $endpoints;
    }
public function addServiceCatalog($type, $name, array $endpoints)
    {
        if (!array_key_exists($type, $this->catalogs)) {
            $this->catalogs[$type] = [];
        }

        // check if endpoints config is correct
        foreach ($endpoints as $index => $endpoint) {
            if (!is_array($endpoint)) {
                throw new TokenException('Expecting an array for an endpoint');
            }

            $endpoints[$index] = array_change_key_case($endpoint, CASE_LOWER);

            if (!isset($endpoints[$index]['publicurl']) && !isset($endpoints[$index]['adminurl'])) {
                throw new TokenException(
                    sprintf('An endpoint must have either a "publicurl" or "adminurl" key, got %s', json_encode($endpoint))
                );
            }
        }

        $this->catalogs[$type][$name] = $endpoints;
    }
public function addServiceCatalog ( $ type , $ name , array $ endpoints ) { if ( ! array_key_exists ( $ type , $ this -> catalogs ) ) { $ this -> catalogs [ $ type ] = [ ] ; } // check if endpoints config is correct foreach ( $ endpoints as $ index => $ endpoint ) { if ( ! is_array ( $ endpoint ) ) { throw new TokenException ( 'Expecting an array for an endpoint' ) ; } $ endpoints [ $ index ] = array_change_key_case ( $ endpoint , CASE_LOWER ) ; if ( ! isset ( $ endpoints [ $ index ] [ 'publicurl' ] ) && ! isset ( $ endpoints [ $ index ] [ 'adminurl' ] ) ) { throw new TokenException ( sprintf ( 'An endpoint must have either a "publicurl" or "adminurl" key, got %s' , json_encode ( $ endpoint ) ) ) ; } } $ this -> catalogs [ $ type ] [ $ name ] = $ endpoints ; }
Adds a service catalog, using the array output of a token-call.

@param string $type      The service type
@param string $name      The service name
@param array  $endpoints Array of endpoints
Adds a service catalog using the array output of a token - call .