Renders an encoded URI.

@param integer $to Render parts (left to right) up to this part.
@param boolean $schemaRelative Create a schema-relative URI?
@return string
184851
public function toString($to = self::TO_FRAGMENT, $schemaRelative = false)
	{
		if($to == static::TO_SCHEME)
		{
			return $this->scheme;
		}
		
		if($schemaRelative || empty($this->scheme))
		{
			$uri = empty($this->host) ? '' : '//';
		}
		else
		{
			$uri = empty($this->host) ? '' : ($this->scheme . '://');
		}
		
		if(isset($this->username) && !empty($this->host))
		{
			$uri .= $this->username;
				
			if(isset($this->password))
			{
				$uri .= ':' . $this->password;
			}
				
			$uri .= '@';
		}
		
		$uri .= $this->getHost(true) . '/';
		
		if($to == static::TO_HOST)
		{
			return $uri;
		}
		
		$uri .= $this->getPath(true);
		
		if($to == static::TO_PATH)
		{
			return $uri;
		}
		
		if(!empty($this->query))
		{
			$uri .= '?' . $this->getQueryString();
		}
		
		if($to == static::TO_QUERY)
		{
			return $uri;
		}
		
		if(!empty($this->fragment))
		{
			$uri .= '#' . $this->fragment;
		}
		
		return $uri;
	}
889193
private function getRelativeUrl($from, $to)
	{
		$relative = '';
		while (true)
		{
			if ($from === $to)
				return $relative;
			else if ($from === dirname($from))
				return $relative . substr($to, 1);
			if (!strncmp($from . '/', $to, strlen($from) + 1))
				return $relative . substr($to, strlen($from) + 1);

			$from = dirname($from);
			$relative .= '../';
		}
	}
1235318
public function render($uri, Request $request, array $options = [])
    {
        if ($uri instanceof ControllerReference) {
            if (null === $this->signer) {
                throw new \LogicException('You must use a proper URI when using the Hinclude rendering strategy or set a URL signer.');
            }

            // we need to sign the absolute URI, but want to return the path only.
            $uri = substr($this->signer->sign($this->generateFragmentUri($uri, $request, true)), \strlen($request->getSchemeAndHttpHost()));
        }

        // We need to replace ampersands in the URI with the encoded form in order to return valid html/xml content.
        $uri = str_replace('&', '&amp;', $uri);

        $template = isset($options['default']) ? $options['default'] : $this->globalDefaultTemplate;
        if (null !== $this->templating && $template && $this->templateExists($template)) {
            $content = $this->templating->render($template);
        } else {
            $content = $template;
        }

        $attributes = isset($options['attributes']) && \is_array($options['attributes']) ? $options['attributes'] : [];
        if (isset($options['id']) && $options['id']) {
            $attributes['id'] = $options['id'];
        }
        $renderedAttributes = '';
        if (\count($attributes) > 0) {
            $flags = ENT_QUOTES | ENT_SUBSTITUTE;
            foreach ($attributes as $attribute => $value) {
                $renderedAttributes .= sprintf(
                    ' %s="%s"',
                    htmlspecialchars($attribute, $flags, $this->charset, false),
                    htmlspecialchars($value, $flags, $this->charset, false)
                );
            }
        }

        return new Response(sprintf('<hx:include src="%s"%s>%s</hx:include>', $uri, $renderedAttributes, $content));
    }
873738
protected function cacheKey(string $key_part): string
    {
        $key = md5('resolveAllUrls'.$key_part.self::SCHEMA_VERSION);

        return $key;
    }
823694
public function getSchema()
    {
        $schemaLocation = $this->documentElement->getAttribute('xsi:schemaLocation');
        if (!$schemaLocation or strpos($schemaLocation, ' ')===false)
            return false;
        list($uri, $xsd) = explode(' ', $schemaLocation);
        return $xsd;
    }
677116
protected static function convertFormToModelRepresentation(
        ContainerInterface $container,
        string $schemaClass,
        array $formData
    ): array {
        assert(self::classImplements($schemaClass, SchemaInterface::class));

        /** @var SchemaInterface $schemaClass */
        $modelClass = $schemaClass::MODEL;
        assert(empty($modelClass) === false);

        $attributes = [];

        /** @var ModelSchemaInfoInterface $modelSchemeInfo */
        $modelSchemeInfo = $container->get(ModelSchemaInfoInterface::class);
        foreach ($formData as $jsonName => $value) {
            if ($schemaClass::hasAttributeMapping($jsonName) === true) {
                $modelAttrName              = $schemaClass::getAttributeMapping($jsonName);
                $attributes[$modelAttrName] = $value;
            } elseif ($schemaClass::hasRelationshipMapping($jsonName) === true) {
                $modelRelName        = $schemaClass::getRelationshipMapping($jsonName);
                $fkName              = $modelSchemeInfo->getForeignKey($modelClass, $modelRelName);
                $attributes[$fkName] = $value;
            }
        }

        return $attributes;
    }
449015
public function getLayoutId(): \Psr\Http\Message\UriInterface
    {
        if (!$this->layoutId) {
            return new Uri();
        }

        return $this->layoutId;
    }
731132
public function serializeURL($excludeFragmentFlag = false)
    {
        $output = $this->scheme . ':';
        if (!is_null($this->host)) {
            $output .= '//';
            if ($this->isIncludingCredentials()) {
                $output .= $this->username;
                if ($this->password !== '') {
                    $output .= ':' . $this->password;
                }
                $output .= '@';
            }
            $output .= HostProcessing::serializeHost($this->host);
            if (!is_null($this->port)) {
                $output .= ':' . $this->port;
            }
        } elseif (is_null($this->host) && $this->scheme === 'file') {
            $output .= '//';
        }
        $output .= $this->cannotBeABaseURLFlag ? $this->path[0] :  '/' . implode('/', $this->path);
        if (!is_null($this->query)) {
            $output .= '?' . $this->query;
        }
        if (!$excludeFragmentFlag && !is_null($this->fragment)) {
            $output .= '#' . $this->fragment;
        }
        return $output;
    }
102664
public function render()
    {
        $title = $this->fetchTitle();

        if ($related = $this->relation->getResults()) {
            return view(app('scaffold.template')->view('relations.one_to_one'), [
                'title' => $title,
                'related' => $related,
            ]);
        }

        return null;
    }
610295
public function replaceBy($sContent, $sOptionToUnescape = '"html"', $sEncoding = '"UTF-8"') {

		$sOptionToUnescape = str_replace("'", '"', $sOptionToUnescape);
		$sEncoding = str_replace("'", '"', $sEncoding);

		if ($sOptionToUnescape === '"htmlall"') {

			return '{html_entity_decode('.$sContent.', ENT_COMPAT | ENT_HTML401, '.$sEncoding.')}';
		}
		else {

			return '{htmlspecialchars_decode('.$sContent.', ENT_COMPAT | ENT_HTML401)}';
		}
	}
157771
function renderTypesWithChildrenToc( types, tocTemplate, transformers ) {
   const tocString = types.map( type =>
      ({
         name: type.name + transformers._deprecationTitle( type ),
         link: `#${type.name}`,
         children: ( type.children || [] )
            .map( member => {
               const commonPrefix = `${type.name}.${member.name}`;
               return {
                  link: `#${commonPrefix}`,
                  name: commonPrefix + ( isFunction( member ) ? '()' : '' ) +
                     transformers._deprecationTitle( member )
               };
            } )
      })
   );

   return tocTemplate( { entries: tocString } ).trim();
}
423160
public function setSchemaDescription($schemaDescription, $locale = null)
    {
        $this->translate($locale, false)->setSchemaDescription($schemaDescription);
        $this->mergeNewTranslations();

        return $this;
    }
878821
private static function key($schema, $uri)
    {
        if ($uri !== '') {
            return sha1($uri);
        }

        return sha1(is_string($schema) ? $schema : json_encode($schema));
    }
1296216
public function getRedirectUrl($returnTo = null)
    {
        $settings = $this->auth->getSettings();
        $authnRequest = new OneLogin_Saml2_AuthnRequest($settings);
        $parameters = array('SAMLRequest' => $authnRequest->getRequest());
        if (!empty($returnTo)) {
            $parameters['RelayState'] = $returnTo;
        } else {
            $parameters['RelayState'] = OneLogin_Saml2_Utils::getSelfRoutedURLNoQuery();
        }
        $url = OneLogin_Saml2_Utils::redirect($this->auth->getSSOurl(), $parameters, true);
        return $url;
    }
1131869
private function processDocument(
        $className,
        array $doctrineMapping,
        \DOMElement $serializerMapping = null,
        array $schemaMapping = null
    ) {
        if ($serializerMapping === null) {
            $serializerFields = [];
        } else {
            $serializerFields = array_reduce(
                $this->getSerializerFields($serializerMapping),
                function (array $fields, array $field) {
                    $fields[$field['fieldName']] = $field;
                    return $fields;
                },
                []
            );
        }

        if ($schemaMapping === null) {
            $schemaFields = [];
        } else {
            $schemaFields = $schemaMapping;
        }

        $fields = [];
        foreach ($this->getDoctrineFields($doctrineMapping) as $doctrineField) {
            $serializerField = isset($serializerFields[$doctrineField['name']]) ?
                $serializerFields[$doctrineField['name']] :
                null;
            $schemaField = isset($schemaFields[$doctrineField['name']]) ?
                $schemaFields[$doctrineField['name']] :
                null;

            if ($doctrineField['type'] === 'collection') {
                $fields[] = new ArrayField(
                    $serializerField === null ? 'array<string>' : $serializerField['fieldType'],
                    $doctrineField['name'],
                    $serializerField === null ? $doctrineField['name'] : $serializerField['exposedName'],
                    !isset($schemaField['readOnly']) ? false : $schemaField['readOnly'],
                    ($schemaField === null || !isset($schemaField['required'])) ? false : $schemaField['required'],
                    !isset($schemaField['recordOriginException']) ? false : $schemaField['recordOriginException'],
                    !isset($schemaField['restrictions']) ? [] : $schemaField['restrictions']
                );
            } else {
                $fields[] = new Field(
                    $doctrineField['type'],
                    $doctrineField['name'],
                    $serializerField === null ? $doctrineField['name'] : $serializerField['exposedName'],
                    !isset($schemaField['readOnly']) ? false : $schemaField['readOnly'],
                    ($schemaField === null || !isset($schemaField['required'])) ? false : $schemaField['required'],
                    $serializerField === null ? false : $serializerField['searchable'],
                    !isset($schemaField['recordOriginException']) ? false : $schemaField['recordOriginException'],
                    !isset($schemaField['restrictions']) ? [] : $schemaField['restrictions']
                );
            }
        }
        foreach ($this->getDoctrineEmbedOneFields($doctrineMapping) as $doctrineField) {
            $serializerField = isset($serializerFields[$doctrineField['name']]) ?
                $serializerFields[$doctrineField['name']] :
                null;
            $schemaField = isset($schemaFields[$doctrineField['name']]) ?
                $schemaFields[$doctrineField['name']] :
                null;

            $fields[] = new EmbedOne(
                $this->getDocument($doctrineField['type']),
                $doctrineField['name'],
                $serializerField === null ? $doctrineField['name'] : $serializerField['exposedName'],
                !isset($schemaField['readOnly']) ? false : $schemaField['readOnly'],
                ($schemaField === null || !isset($schemaField['required'])) ? false : $schemaField['required'],
                !isset($schemaField['recordOriginException']) ? false : $schemaField['recordOriginException'],
                !isset($schemaField['restrictions']) ? [] : $schemaField['restrictions']
            );
        }
        foreach ($this->getDoctrineEmbedManyFields($doctrineMapping) as $doctrineField) {
            $serializerField = isset($serializerFields[$doctrineField['name']]) ?
                $serializerFields[$doctrineField['name']] :
                null;
            $schemaField = isset($schemaFields[$doctrineField['name']]) ?
                $schemaFields[$doctrineField['name']] :
                null;

            $fields[] = new EmbedMany(
                $this->getDocument($doctrineField['type']),
                $doctrineField['name'],
                $serializerField === null ? $doctrineField['name'] : $serializerField['exposedName'],
                !isset($schemaField['readOnly']) ? false : $schemaField['readOnly'],
                ($schemaField === null || !isset($schemaField['required'])) ? false : $schemaField['required'],
                !isset($schemaField['recordOriginException']) ? false : $schemaField['recordOriginException'],
                !isset($schemaField['restrictions']) ? [] : $schemaField['restrictions']
            );
        }

        $doc = new Document($className, $fields);

        // stuff that belongs to the whole document
        if (isset($schemaMapping['_base']['solr']['fields'])) {
            $doc->setSolrFields($schemaMapping['_base']['solr']['fields']);
        }
        if (isset($schemaMapping['_base']['solr']['aggregate'])) {
            $doc->setSolrAggregate($schemaMapping['_base']['solr']['aggregate']);
        }

        return $doc;
    }
277669
protected static function getSchema()
    {
        static $cache = null;
        if (!isset($cache)) {
            $schemaFile = __DIR__.'/doctrine-xml-0.5.xsd';
            $s = (is_file($schemaFile) && is_readable($schemaFile)) ? @file_get_contents($schemaFile) : false;
            if ($s === false) {
                throw new Exception('Failed to load the schema file '.$schemaFile);
            }
            $cache = $s;
        }

        return $cache;
    }
1202699
public static function resolveRelatedPath($from, $to)
    {
        $from_parts = array_filter( explode('/', $from) );
        $to_parts = array_filter( explode('/', $to) );
        foreach($from_parts as $i=>$path) {
            if (in_array($path, $to_parts)) {
                $from_parts[$i] = null;
                $to_parts[$i] = null;
            }
        }
        $from_parts = array_filter($from_parts);
        $to_parts = array_filter($to_parts);
        for($i=0; $i<count($from_parts); $i++) {
            array_unshift($to_parts, '..');
        }
/*
        foreach($from_parts as $path) {
            array_unshift($to_parts, $path);
        }
*/
        return join('/', $to_parts);
    }