private function resolveString($value, array $resolving = [])
    {
        if (preg_match('/^%([^%\s]+)%$/', $value, $match)) {
            if (null !== $ret = $this->parseEnvironmentParams($match[1])) {
                return $ret;
            }

            $key = $match[1];

            if (isset($resolving[$key])) {
                throw new RuntimeException("Circular reference detected for parameter '$key'.");
            }

            $resolving[$key] = true;

            return $this->resolved ? $this->get($key) : $this->resolveValue($this->get($key), $resolving);
        }

        $self = $this;

        return preg_replace_callback('/%%|%([^%\s]+)%/', function ($match) use ($self, $resolving, $value) {
            // skip %%
            if (!isset($match[1])) {
                return '%%';
            }

            if (null !== $ret = $this->parseEnvironmentParams($match[1])) {
                return $ret;
            }

            $key = $match[1];
            if (isset($resolving[$key])) {
                throw new RuntimeException(sprintf("Circular reference detected for parameter '$key'."));
            }

            $resolved = $this->get($key);

            if (!is_string($resolved) && !is_numeric($resolved)) {
                throw new RuntimeException(sprintf('A string value must be composed of strings and/or numbers, but found parameter "%s" of type %s inside string value "%s".', $key, gettype($resolved), $value));
            }

            $resolved = (string) $resolved;
            $resolving[$key] = true;

            return $self->isResolved() ? $resolved : $self->resolveString($resolved, $resolving);
        }, $value);
    }
private function resolveString($value, array $resolving = [])
    {
        if (preg_match('/^%([^%\s]+)%$/', $value, $match)) {
            if (null !== $ret = $this->parseEnvironmentParams($match[1])) {
                return $ret;
            }

            $key = $match[1];

            if (isset($resolving[$key])) {
                throw new RuntimeException("Circular reference detected for parameter '$key'.");
            }

            $resolving[$key] = true;

            return $this->resolved ? $this->get($key) : $this->resolveValue($this->get($key), $resolving);
        }

        $self = $this;

        return preg_replace_callback('/%%|%([^%\s]+)%/', function ($match) use ($self, $resolving, $value) {
            // skip %%
            if (!isset($match[1])) {
                return '%%';
            }

            if (null !== $ret = $this->parseEnvironmentParams($match[1])) {
                return $ret;
            }

            $key = $match[1];
            if (isset($resolving[$key])) {
                throw new RuntimeException(sprintf("Circular reference detected for parameter '$key'."));
            }

            $resolved = $this->get($key);

            if (!is_string($resolved) && !is_numeric($resolved)) {
                throw new RuntimeException(sprintf('A string value must be composed of strings and/or numbers, but found parameter "%s" of type %s inside string value "%s".', $key, gettype($resolved), $value));
            }

            $resolved = (string) $resolved;
            $resolving[$key] = true;

            return $self->isResolved() ? $resolved : $self->resolveString($resolved, $resolving);
        }, $value);
    }
private function resolveString ( $ value , array $ resolving = [ ] ) { if ( preg_match ( '/^%([^%\s]+)%$/' , $ value , $ match ) ) { if ( null !== $ ret = $ this -> parseEnvironmentParams ( $ match [ 1 ] ) ) { return $ ret ; } $ key = $ match [ 1 ] ; if ( isset ( $ resolving [ $ key ] ) ) { throw new RuntimeException ( "Circular reference detected for parameter '$key'." ) ; } $ resolving [ $ key ] = true ; return $ this -> resolved ? $ this -> get ( $ key ) : $ this -> resolveValue ( $ this -> get ( $ key ) , $ resolving ) ; } $ self = $ this ; return preg_replace_callback ( '/%%|%([^%\s]+)%/' , function ( $ match ) use ( $ self , $ resolving , $ value ) { // skip %% if ( ! isset ( $ match [ 1 ] ) ) { return '%%' ; } if ( null !== $ ret = $ this -> parseEnvironmentParams ( $ match [ 1 ] ) ) { return $ ret ; } $ key = $ match [ 1 ] ; if ( isset ( $ resolving [ $ key ] ) ) { throw new RuntimeException ( sprintf ( "Circular reference detected for parameter '$key'." ) ) ; } $ resolved = $ this -> get ( $ key ) ; if ( ! is_string ( $ resolved ) && ! is_numeric ( $ resolved ) ) { throw new RuntimeException ( sprintf ( 'A string value must be composed of strings and/or numbers, but found parameter "%s" of type %s inside string value "%s".' , $ key , gettype ( $ resolved ) , $ value ) ) ; } $ resolved = ( string ) $ resolved ; $ resolving [ $ key ] = true ; return $ self -> isResolved ( ) ? $ resolved : $ self -> resolveString ( $ resolved , $ resolving ) ; } , $ value ) ; }
Resolves parameters inside a string

@param string $value     The string to resolve
@param array  $resolving An array of keys that are being resolved (used internally to detect circular references)

@return string                                                   The resolved string
@throws \Propel\Common\Config\Exception\RuntimeException         if a problem occurs
@throws \Propel\Common\Config\Exception\InvalidArgumentException if a parameter is non-existent
Resolves parameters inside a string