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
515427
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;
    }
150483
def add_endpoint(self, ep):
        """"""
        assert ep.name not in self.endpoints, ep
        self.endpoints[ep.name] = ep
503507
protected function addArray($name, $xsdType)
    {
        if (isset($this->types[$name])) {
            return $this->types[$name];
        }
        //create the complexType tag beneath the xsd:schema tag
        $complexTypeTag = $this->addElement('xsd:complexType', $this->parentElement);
        $complexTypeTag->setAttribute('name', $name);
        $this->types[$name] = $complexTypeTag;

        $cc = $this->addElement('xsd:complexContent', $complexTypeTag);

        $rs = $this->addElement('xsd:restriction', $cc);
        $rs->setAttribute('base', 'SOAP-ENC:Array');

        $el = $this->addElement('xsd:attribute', $rs);
        $el->setAttribute('ref', 'SOAP-ENC:arrayType');
        $el->setAttribute('wsdl:arrayType', $xsdType.'[]');
    }
1227922
public function getEndpoint($serviceType, $region, $endpointType = 'public')
	{
		$serviceEndpoints = $this->getEndpoints($serviceType);
		foreach ($serviceEndpoints as $endpointsRegion => $endpoints) {
			if ($endpointsRegion == $region) {
				return $endpoints[$endpointType . 'URL'];
			}
		}
	}
582808
public function addNextStateOr($name, $type, array $targets)
    {
        $this->nextStates[$name] = new NextStateOr($name, $type, $targets);
    }
864417
public function addTemplate($name, $type = self::TEMPLATE_START, $file) {
        if ($this->_enabled == true) {
            switch ($type) {
                case self::TEMPLATE_START:
                    $this->_template[$file]['name'] = $name;
                    $this->_template[$file]['time'] = microtime(true);
                    break;

                case self::TEMPLATE_END:
                    $this->_template[$file]['time'] = round((microtime(true) - $this->_template[$file]['time']) * 1000, 4);
                    break;
            }
        }
    }
279877
public function supports(string $name, string $type): bool
    {
        switch ($type) {
            case DSL::TYPE_QUERY:
                return \in_array($name, $this->queries, true);
            case DSL::TYPE_AGGREGATION:
                return \in_array($name, $this->aggregations, true);
            case DSL::TYPE_SUGGEST:
                return \in_array($name, $this->suggesters, true);
        }

        // disables version check in Facade for custom DSL objects
        return true;
    }
1221850
function load_filter($type, $name)
	{
		switch ($type) {
			case 'output':
				$_params = array('plugins' => array(array($type . 'filter', $name, null, null, false)));
				require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
				smarty_core_load_plugins($_params, $this);
				break;

			case 'pre':
			case 'post':
				if (!isset($this->_plugins[$type . 'filter'][$name]))
				$this->_plugins[$type . 'filter'][$name] = false;
				break;
		}
	}
723141
public function argument($type, $name) {
        $argument = new Argument($type, $name);
        $this->addArgument($argument);

        return $argument;
    }
190169
private function addFilters(ExecutableDefinitionInterface $definition, string $targetType, Endpoint $endpoint): void
    {
        $filterName = ucfirst($definition->getName()).'Filter';
        if ($endpoint->hasType($filterName)) {
            $filters = $endpoint->getType($filterName);
        } else {
            $filters = new InputObjectDefinition();
            $filters->setName($filterName);
            $endpoint->add($filters);

            $object = $endpoint->getType($targetType);
            if ($object instanceof FieldsAwareDefinitionInterface) {
                foreach ($object->getFields() as $field) {
                    if ('id' === $field->getName()
                        || !$field->getOriginName()
                        || \ReflectionProperty::class !== $field->getOriginType()) {
                        continue;
                    }

                    $filter = new FieldDefinition();
                    $filter->setName($field->getName());
                    $type = $field->getType();
                    if ($endpoint->hasType($type)) {
                        $typeDefinition = $endpoint->getType($type);
                        if (!$typeDefinition instanceof EnumDefinition) {
                            $type = 'ID';
                        }
                        $filter->setList(true);
                    }

                    // fields using custom object as type
                    // are not available for filters
                    if (TypeRegistry::getTypeMapp()) {
                        if (isset(TypeRegistry::getTypeMapp()[$type])) {
                            $class = TypeRegistry::getTypeMapp()[$type];
                            $ref = new \ReflectionClass($class);
                            if ($ref->isSubclassOf(ObjectType::class)) {
                                continue;
                            }
                        }
                    }

                    $filter->setType($type);
                    $filters->addField($filter);
                }
            }
        }

        if (!$filters->getFields()) {
            return;
        }

        $search = new ArgumentDefinition();
        $search->setName('filters');
        $search->setType($filters->getName());
        $deprecateMessage = \is_string($this->bcConfig['filters']) ? $this->bcConfig['filters'] : '**DEPRECATED** use `where` instead to filter the list.';
        $search->setDescription($deprecateMessage);
        $search->setNonNull(false);
        $definition->addArgument($search);
    }
1294769
public function addParameter($type, $name) {

        if ( !in_array($type, self::$rpcvalues) ) throw new InvalidArgumentException("Invalid type for parameter $name");

        if ( empty($name) ) throw new InvalidArgumentException("Missing parameter name");

        $this->signatures[$this->current_signature]["PARAMETERS"][$name] = self::$rpcvalues[$type];

        return $this;

    }
1369811
protected function buildUrl($endpoint = '', $type = 'api')
    {
        //Get the base path
        $base = $this->getBasePath();

        //If the endpoint type is 'upload'
        if ($type === 'upload') {
            //Get the Content Path
            $base = $this->getUploadPath();
        }

        //Join and return the base and api path/endpoint
        return $base . $endpoint;
    }
929580
public function addI18NColumn($type, $name, array $parameters = [])
    {
        $this->i18n_columns[] = $column = parent::addColumn($type, $name, $parameters);

        return $column;
    }
789736
public function fillEndPoint(string &$endPoint): void
    {
        $endPoint = str_replace("{sms}", $this->smsID, $endPoint);
        $endPoint = str_replace("{bundle}", $this->bundleID ?? "", $endPoint);
    }
1160312
protected function register(
        string $type,
        $name,
        string $source,
        $dependencies,
        $attributes,
        $replaces
    ): void {
        $dependencies = (array) $dependencies;
        $attributes = (array) $attributes;
        $replaces = (array) $replaces;

        if (\is_array($name)) {
            $replaces = \array_merge($name, $replaces);
            $name = '*';
        }

        $this->assets[$type][$name] = [
            'source' => $source,
            'dependencies' => $dependencies,
            'attributes' => $attributes,
            'replaces' => $replaces,
        ];
    }
469490
protected function addComplexType($type, $name = false, $parent = false)
    {
        if (!$parent) {
            //outline element
            //check if the complexType doesn't already exists
            if (isset($this->types[$name])) {
                return $this->types[$name];
            }
            //create the complexType tag beneath the xsd:schema tag
            $complexTypeTag = $this->addElement('xsd:complexType', $this->parentElement);
            if ($name) {
                //might be an anonymous element
                $complexTypeTag->setAttribute('name', $name);
                $this->types[$name] = $complexTypeTag;
            }
        } else {
            //inline element
            $complexTypeTag = $this->addElement('xsd:complexType', $parent);
        }

        $tag = $this->addElement('xsd:all', $complexTypeTag);
        //check if it has the name 'object()' (kind of a stdClass)
        if (strtolower(substr($type, 0, 6)) == 'object') {
            //stdClass
            $content = substr($type, 7, -1);
            $properties = explode(',', $content);//split the content into properties
            foreach ($properties as $property) {
                if (strpos($property, '=>') !== false) {
                    //array with keys (order is important, so use 'sequence' tag)
                    list($keyType, $valueType) = explode('=>', $property);
                    $el = $this->addTypeElement($valueType, $keyType, $tag);
                } else {
                    throw new WSDLException('Error creating WSDL: expected "=>". When using the object() as type, use it as object(paramname=>paramtype,paramname2=>paramtype2)', 100);
                }
            }
        } else { //should be a known class
            if (!class_exists($name)) {
                throw new WSDLException("Error creating WSDL: no class found with the name '$name' / $type : $parent, so how should we know the structure for this datatype?", 101);
            }
            $v = new IPReflectionClass($name);
            $properties = $v->getProperties(false, false, false);//not protected and private properties

            foreach ((array) $properties as $property) {
                if (!$property->isPrivate) {
                    $el = $this->addTypeElement($property->type, $property->name, $tag, $property->optional);
                }
            }
        }

        return $complexTypeTag;
    }
628649
public function registerToken($type = 'ERC20', $name, $symbol, $address)
    {
        $response = $this->apiClient->post('tokens/register', [
            'token_type' => $type,
            'name' => $name,
            'symbol' => $symbol,
            'address' => $address,
        ]);
        
        if (!isset($response['uid'])) throw new \ErrorException('Unexpected API response: ' . print_r($response, true));
        return $this->getToken($response['uid']);
    }